Update to shared_ptr-less parser interface.
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
#ifndef OPM_OUTPUT_WRITER_HPP
|
||||
#define OPM_OUTPUT_WRITER_HPP
|
||||
|
||||
#include <memory> // unique_ptr, shared_ptr
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/NNC.hpp>
|
||||
|
||||
#include <opm/output/Cells.hpp>
|
||||
|
||||
@@ -43,18 +43,18 @@ namespace Opm
|
||||
CornerPointChopper(const std::string& file)
|
||||
{
|
||||
Opm::ParseContext parseContext;
|
||||
Opm::ParserPtr parser(new Opm::Parser());
|
||||
deck_ = parser->parseFile(file , parseContext);
|
||||
Opm::Parser parser;
|
||||
deck_ = parser.parseFile(file , parseContext);
|
||||
|
||||
metricUnits_.reset(Opm::UnitSystem::newMETRIC());
|
||||
|
||||
const auto& specgridRecord = deck_->getKeyword("SPECGRID").getRecord(0);
|
||||
const auto& specgridRecord = deck_.getKeyword("SPECGRID").getRecord(0);
|
||||
dims_[0] = specgridRecord.getItem("NX").get< int >(0);
|
||||
dims_[1] = specgridRecord.getItem("NY").get< int >(0);
|
||||
dims_[2] = specgridRecord.getItem("NZ").get< int >(0);
|
||||
|
||||
int layersz = 8*dims_[0]*dims_[1];
|
||||
const std::vector<double>& ZCORN = deck_->getKeyword("ZCORN").getRawDoubleData();
|
||||
const std::vector<double>& ZCORN = deck_.getKeyword("ZCORN").getRawDoubleData();
|
||||
botmax_ = *std::max_element(ZCORN.begin(), ZCORN.begin() + layersz/2);
|
||||
topmin_ = *std::min_element(ZCORN.begin() + dims_[2]*layersz - layersz/2,
|
||||
ZCORN.begin() + dims_[2]*layersz);
|
||||
@@ -144,7 +144,7 @@ namespace Opm
|
||||
new_dims_[1] = jmax - jmin;
|
||||
|
||||
// Filter the coord field
|
||||
const std::vector<double>& COORD = deck_->getKeyword("COORD").getRawDoubleData();
|
||||
const std::vector<double>& COORD = deck_.getKeyword("COORD").getRawDoubleData();
|
||||
int num_coord = COORD.size();
|
||||
if (num_coord != 6*(dims_[0] + 1)*(dims_[1] + 1)) {
|
||||
std::cerr << "Error! COORD size (" << COORD.size() << ") not consistent with SPECGRID\n";
|
||||
@@ -177,7 +177,7 @@ namespace Opm
|
||||
// coordinate of the bottom surface, while zmax must be less than or
|
||||
// equal to the lowest coordinate of the top surface.
|
||||
int layersz = 8*dims_[0]*dims_[1];
|
||||
const std::vector<double>& ZCORN = deck_->getKeyword("ZCORN").getRawDoubleData();
|
||||
const std::vector<double>& ZCORN = deck_.getKeyword("ZCORN").getRawDoubleData();
|
||||
int num_zcorn = ZCORN.size();
|
||||
if (num_zcorn != layersz*dims_[2]) {
|
||||
std::cerr << "Error! ZCORN size (" << ZCORN.size() << ") not consistent with SPECGRID\n";
|
||||
@@ -256,9 +256,9 @@ namespace Opm
|
||||
}
|
||||
|
||||
/// Return a sub-deck with fields corresponding to the selected subset.
|
||||
Opm::DeckConstPtr subDeck()
|
||||
Opm::Deck subDeck()
|
||||
{
|
||||
Opm::DeckPtr subDeck(new Opm::Deck);
|
||||
Opm::Deck subDeck;
|
||||
|
||||
Opm::DeckKeyword specGridKw("SPECGRID");
|
||||
Opm::DeckRecord specGridRecord;
|
||||
@@ -283,7 +283,7 @@ namespace Opm
|
||||
|
||||
specGridKw.addRecord(std::move(specGridRecord));
|
||||
|
||||
subDeck->addKeyword(std::move(specGridKw));
|
||||
subDeck.addKeyword(std::move(specGridKw));
|
||||
addDoubleKeyword_(subDeck, "COORD", /*dimension=*/"Length", new_COORD_);
|
||||
addDoubleKeyword_(subDeck, "ZCORN", /*dimension=*/"Length", new_ZCORN_);
|
||||
addIntKeyword_(subDeck, "ACTNUM", new_ACTNUM_);
|
||||
@@ -328,8 +328,8 @@ namespace Opm
|
||||
bool hasSOWCR() const {return !new_SOWCR_.empty(); }
|
||||
|
||||
private:
|
||||
Opm::DeckConstPtr deck_;
|
||||
std::shared_ptr<Opm::UnitSystem> metricUnits_;
|
||||
Opm::Deck deck_;
|
||||
Opm::UnitSystem metricUnits_;
|
||||
|
||||
double botmax_;
|
||||
double topmin_;
|
||||
@@ -350,7 +350,7 @@ namespace Opm
|
||||
int new_dims_[3];
|
||||
std::vector<int> new_to_old_cell_;
|
||||
|
||||
void addDoubleKeyword_(Opm::DeckPtr subDeck,
|
||||
void addDoubleKeyword_(Deck& subDeck,
|
||||
const std::string& keywordName,
|
||||
const std::string& dimensionString,
|
||||
const std::vector<double>& data)
|
||||
@@ -371,10 +371,10 @@ namespace Opm
|
||||
|
||||
dataRecord.addItem(std::move(dataItem));
|
||||
dataKw.addRecord(std::move(dataRecord));
|
||||
subDeck->addKeyword(std::move(dataKw));
|
||||
subDeck.addKeyword(std::move(dataKw));
|
||||
}
|
||||
|
||||
void addIntKeyword_(Opm::DeckPtr subDeck,
|
||||
void addIntKeyword_(Deck& subDeck,
|
||||
const std::string& keywordName,
|
||||
const std::vector<int>& data)
|
||||
{
|
||||
@@ -391,7 +391,7 @@ namespace Opm
|
||||
|
||||
dataRecord.addItem(std::move(dataItem));
|
||||
dataKw.addRecord(std::move(dataRecord));
|
||||
subDeck->addKeyword(std::move(dataKw));
|
||||
subDeck.addKeyword(std::move(dataKw));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -432,16 +432,16 @@ namespace Opm
|
||||
|
||||
void filterDoubleField(const std::string& keyword, std::vector<double>& output_field)
|
||||
{
|
||||
if (deck_->hasKeyword(keyword)) {
|
||||
const std::vector<double>& field = deck_->getKeyword(keyword).getRawDoubleData();
|
||||
if (deck_.hasKeyword(keyword)) {
|
||||
const std::vector<double>& field = deck_.getKeyword(keyword).getRawDoubleData();
|
||||
filterField(field, output_field);
|
||||
}
|
||||
}
|
||||
|
||||
void filterIntegerField(const std::string& keyword, std::vector<int>& output_field)
|
||||
{
|
||||
if (deck_->hasKeyword(keyword)) {
|
||||
const std::vector<int>& field = deck_->getKeyword(keyword).getIntData();
|
||||
if (deck_.hasKeyword(keyword)) {
|
||||
const std::vector<int>& field = deck_.getKeyword(keyword).getIntData();
|
||||
filterField(field, output_field);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class EclipseGridInspector
|
||||
public:
|
||||
/// Constructor taking a parser as argument.
|
||||
/// The parser must already have read an Eclipse file.
|
||||
EclipseGridInspector(Opm::DeckConstPtr deck);
|
||||
EclipseGridInspector(Opm::Deck);
|
||||
|
||||
/// Assuming that the pillars are vertical, compute the
|
||||
/// volume of the cell given by logical coordinates (i, j, k).
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
std::array<double, 8> cellZvals(int i, int j, int k) const;
|
||||
|
||||
private:
|
||||
Opm::DeckConstPtr deck_;
|
||||
Opm::Deck deck_;
|
||||
int logical_gridsize_[3];
|
||||
void init_();
|
||||
void checkLogicalCoords(int i, int j, int k) const;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#ifndef OPM_ECLIPSE_WRITER_HPP
|
||||
#define OPM_ECLIPSE_WRITER_HPP
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/NNC.hpp>
|
||||
|
||||
#include <string>
|
||||
@@ -47,7 +48,7 @@ public:
|
||||
* \brief Sets the common attributes required to write eclipse
|
||||
* binary files using ERT.
|
||||
*/
|
||||
EclipseWriter(std::shared_ptr< const EclipseState >, EclipseGrid grid);
|
||||
EclipseWriter( const EclipseState&, EclipseGrid );
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -54,30 +54,30 @@
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
EclipseGridInspector::EclipseGridInspector(Opm::DeckConstPtr deck)
|
||||
: deck_(deck)
|
||||
EclipseGridInspector::EclipseGridInspector(Opm::Deck deck)
|
||||
: deck_( std::move( deck ) )
|
||||
{
|
||||
init_();
|
||||
}
|
||||
|
||||
void EclipseGridInspector::init_()
|
||||
{
|
||||
if (!deck_->hasKeyword("COORD")) {
|
||||
if (!deck_.hasKeyword("COORD")) {
|
||||
OPM_THROW(std::runtime_error, "Needed field \"COORD\" is missing in file");
|
||||
}
|
||||
if (!deck_->hasKeyword("ZCORN")) {
|
||||
if (!deck_.hasKeyword("ZCORN")) {
|
||||
OPM_THROW(std::runtime_error, "Needed field \"ZCORN\" is missing in file");
|
||||
}
|
||||
|
||||
if (deck_->hasKeyword("SPECGRID")) {
|
||||
if (deck_.hasKeyword("SPECGRID")) {
|
||||
const auto& specgridRecord =
|
||||
deck_->getKeyword("SPECGRID").getRecord(0);
|
||||
deck_.getKeyword("SPECGRID").getRecord(0);
|
||||
logical_gridsize_[0] = specgridRecord.getItem("NX").get< int >(0);
|
||||
logical_gridsize_[1] = specgridRecord.getItem("NY").get< int >(0);
|
||||
logical_gridsize_[2] = specgridRecord.getItem("NZ").get< int >(0);
|
||||
} else if (deck_->hasKeyword("DIMENS")) {
|
||||
} else if (deck_.hasKeyword("DIMENS")) {
|
||||
const auto& dimensRecord =
|
||||
deck_->getKeyword("DIMENS").getRecord(0);
|
||||
deck_.getKeyword("DIMENS").getRecord(0);
|
||||
logical_gridsize_[0] = dimensRecord.getItem("NX").get< int >(0);
|
||||
logical_gridsize_[1] = dimensRecord.getItem("NY").get< int >(0);
|
||||
logical_gridsize_[2] = dimensRecord.getItem("NZ").get< int >(0);
|
||||
@@ -100,13 +100,13 @@ std::pair<double,double> EclipseGridInspector::cellDips(int i, int j, int k) con
|
||||
{
|
||||
checkLogicalCoords(i, j, k);
|
||||
const std::vector<double>& pillc =
|
||||
deck_->getKeyword("COORD").getSIDoubleData();
|
||||
deck_.getKeyword("COORD").getSIDoubleData();
|
||||
int num_pillars = (logical_gridsize_[0] + 1)*(logical_gridsize_[1] + 1);
|
||||
if (6*num_pillars != int(pillc.size())) {
|
||||
throw std::runtime_error("Wrong size of COORD field.");
|
||||
}
|
||||
const std::vector<double>& z =
|
||||
deck_->getKeyword("ZCORN").getSIDoubleData();
|
||||
deck_.getKeyword("ZCORN").getSIDoubleData();
|
||||
int num_cells = logical_gridsize_[0]*logical_gridsize_[1]*logical_gridsize_[2];
|
||||
if (8*num_cells != int(z.size())) {
|
||||
throw std::runtime_error("Wrong size of ZCORN field");
|
||||
@@ -210,13 +210,13 @@ double EclipseGridInspector::cellVolumeVerticalPillars(int i, int j, int k) cons
|
||||
// Checking parameters and obtaining values from parser.
|
||||
checkLogicalCoords(i, j, k);
|
||||
const std::vector<double>& pillc =
|
||||
deck_->getKeyword("COORD").getSIDoubleData();
|
||||
deck_.getKeyword("COORD").getSIDoubleData();
|
||||
int num_pillars = (logical_gridsize_[0] + 1)*(logical_gridsize_[1] + 1);
|
||||
if (6*num_pillars != int(pillc.size())) {
|
||||
throw std::runtime_error("Wrong size of COORD field.");
|
||||
}
|
||||
const std::vector<double>& z =
|
||||
deck_->getKeyword("ZCORN").getSIDoubleData();
|
||||
deck_.getKeyword("ZCORN").getSIDoubleData();
|
||||
int num_cells = logical_gridsize_[0]*logical_gridsize_[1]*logical_gridsize_[2];
|
||||
if (8*num_cells != int(z.size())) {
|
||||
throw std::runtime_error("Wrong size of ZCORN field");
|
||||
@@ -274,12 +274,12 @@ void EclipseGridInspector::checkLogicalCoords(int i, int j, int k) const
|
||||
|
||||
std::array<double, 6> EclipseGridInspector::getGridLimits() const
|
||||
{
|
||||
if (! (deck_->hasKeyword("COORD") && deck_->hasKeyword("ZCORN") && deck_->hasKeyword("SPECGRID")) ) {
|
||||
if (! (deck_.hasKeyword("COORD") && deck_.hasKeyword("ZCORN") && deck_.hasKeyword("SPECGRID")) ) {
|
||||
throw std::runtime_error("EclipseGridInspector: Grid does not have SPECGRID, COORD, and ZCORN, can't find dimensions.");
|
||||
}
|
||||
|
||||
std::vector<double> coord = deck_->getKeyword("COORD").getSIDoubleData();
|
||||
std::vector<double> zcorn = deck_->getKeyword("ZCORN").getSIDoubleData();
|
||||
std::vector<double> coord = deck_.getKeyword("COORD").getSIDoubleData();
|
||||
std::vector<double> zcorn = deck_.getKeyword("ZCORN").getSIDoubleData();
|
||||
|
||||
double xmin = +DBL_MAX;
|
||||
double xmax = -DBL_MAX;
|
||||
@@ -328,7 +328,7 @@ std::array<int, 3> EclipseGridInspector::gridSize() const
|
||||
std::array<double, 8> EclipseGridInspector::cellZvals(int i, int j, int k) const
|
||||
{
|
||||
// Get the zcorn field.
|
||||
const std::vector<double>& z = deck_->getKeyword("ZCORN").getSIDoubleData();
|
||||
const std::vector<double>& z = deck_.getKeyword("ZCORN").getSIDoubleData();
|
||||
int num_cells = logical_gridsize_[0]*logical_gridsize_[1]*logical_gridsize_[2];
|
||||
if (8*num_cells != int(z.size())) {
|
||||
throw std::runtime_error("Wrong size of ZCORN field");
|
||||
|
||||
@@ -156,16 +156,16 @@ std::pair< data::Solution, data::Wells >
|
||||
init_from_restart_file( const EclipseState& es, int numcells ) {
|
||||
|
||||
const InitConfig& initConfig = es.getInitConfig();
|
||||
IOConfigConstPtr ioConfig = es.getIOConfig();
|
||||
const auto& ioConfig = es.getIOConfig();
|
||||
int restart_step = initConfig.getRestartStep();
|
||||
const std::string& restart_file_root = initConfig.getRestartRootName();
|
||||
bool output = false;
|
||||
const std::string filename = ioConfig->getRestartFileName(
|
||||
const std::string filename = ioConfig.getRestartFileName(
|
||||
restart_file_root,
|
||||
restart_step,
|
||||
output);
|
||||
const bool unified = ioConfig->getUNIFIN();
|
||||
const int num_wells = es.getSchedule()->numWells( restart_step );
|
||||
const bool unified = ioConfig.getUNIFIN();
|
||||
const int num_wells = es.getSchedule().numWells( restart_step );
|
||||
const int num_phases = es.getTableManager().getNumPhases();
|
||||
|
||||
using ft = ERT::ert_unique_ptr< ecl_file_type, ecl_file_close >;
|
||||
|
||||
@@ -213,11 +213,11 @@ public:
|
||||
const Well& well,
|
||||
size_t offset ) const {
|
||||
|
||||
CompletionSetConstPtr completions = well.getCompletions( step );
|
||||
const auto& completions = well.getCompletions( step );
|
||||
|
||||
data[ offset + IWEL_HEADI_INDEX ] = well.getHeadI() + 1;
|
||||
data[ offset + IWEL_HEADJ_INDEX ] = well.getHeadJ() + 1;
|
||||
data[ offset + IWEL_CONNECTIONS_INDEX ] = completions->size();
|
||||
data[ offset + IWEL_CONNECTIONS_INDEX ] = completions.size();
|
||||
data[ offset + IWEL_GROUP_INDEX ] = 1;
|
||||
|
||||
data[ offset + IWEL_TYPE_INDEX ] = to_ert_welltype( well, step );
|
||||
@@ -226,11 +226,11 @@ public:
|
||||
}
|
||||
|
||||
void addRestartFileIconData( std::vector< int >& data,
|
||||
CompletionSetConstPtr completions,
|
||||
const CompletionSet& completions,
|
||||
size_t wellICONOffset ) const {
|
||||
|
||||
for( size_t i = 0; i < completions->size(); ++i ) {
|
||||
const auto& completion = *completions->get( i );
|
||||
for( size_t i = 0; i < completions.size(); ++i ) {
|
||||
const auto& completion = completions.get( i );
|
||||
size_t offset = wellICONOffset + i * Restart::NICONZ;
|
||||
data[ offset + ICON_IC_INDEX ] = 1;
|
||||
|
||||
@@ -327,10 +327,11 @@ RFT::RFT( const char* output_dir,
|
||||
{}
|
||||
|
||||
inline ert_ecl_unit_enum to_ert_unit( UnitSystem::UnitType t ) {
|
||||
using ut = UnitSystem::UnitType;
|
||||
switch ( t ) {
|
||||
case UnitSystem::UNIT_TYPE_METRIC: return ERT_ECL_METRIC_UNITS;
|
||||
case UnitSystem::UNIT_TYPE_FIELD: return ERT_ECL_FIELD_UNITS;
|
||||
case UnitSystem::UNIT_TYPE_LAB: return ERT_ECL_LAB_UNITS;
|
||||
case ut::UNIT_TYPE_METRIC: return ERT_ECL_METRIC_UNITS;
|
||||
case ut::UNIT_TYPE_FIELD: return ERT_ECL_FIELD_UNITS;
|
||||
case ut::UNIT_TYPE_LAB: return ERT_ECL_LAB_UNITS;
|
||||
}
|
||||
|
||||
throw std::invalid_argument("unhandled enum value");
|
||||
@@ -357,10 +358,10 @@ void RFT::writeTimeStep( std::vector< const Well* > wells,
|
||||
auto* rft_node = ecl_rft_node_alloc_new( well->name().c_str(), "RFT",
|
||||
current_time, days );
|
||||
|
||||
for( const auto& completion : *well->getCompletions( report_step ) ) {
|
||||
const size_t i = size_t( completion->getI() );
|
||||
const size_t j = size_t( completion->getJ() );
|
||||
const size_t k = size_t( completion->getK() );
|
||||
for( const auto& completion : well->getCompletions( report_step ) ) {
|
||||
const size_t i = size_t( completion.getI() );
|
||||
const size_t j = size_t( completion.getJ() );
|
||||
const size_t k = size_t( completion.getK() );
|
||||
|
||||
if( !grid.cellActive( i, j, k ) ) continue;
|
||||
|
||||
@@ -392,12 +393,11 @@ inline std::string uppercase( std::string x ) {
|
||||
|
||||
class EclipseWriter::Impl {
|
||||
public:
|
||||
Impl( std::shared_ptr< const EclipseState > es, EclipseGrid&& grid);
|
||||
Impl( std::shared_ptr< const EclipseState > es, const EclipseGrid& grid);
|
||||
Impl( const EclipseState& es, EclipseGrid grid );
|
||||
void writeINITFile( const data::Solution& simProps, const NNC& nnc) const;
|
||||
void writeEGRIDFile( const NNC& nnc ) const;
|
||||
|
||||
std::shared_ptr< const EclipseState > es;
|
||||
const EclipseState& es;
|
||||
EclipseGrid grid;
|
||||
std::unordered_map<int , std::vector<size_t>> regionCells;
|
||||
std::string outputDir;
|
||||
@@ -411,37 +411,21 @@ class EclipseWriter::Impl {
|
||||
bool first_restart = true;
|
||||
};
|
||||
|
||||
EclipseWriter::Impl::Impl( std::shared_ptr< const EclipseState > eclipseState,
|
||||
EclipseGrid&& grid_)
|
||||
EclipseWriter::Impl::Impl( const EclipseState& eclipseState,
|
||||
EclipseGrid grid_)
|
||||
: es( eclipseState )
|
||||
, grid( std::move(grid_) )
|
||||
, outputDir( eclipseState->getIOConfig()->getOutputDir() )
|
||||
, baseName( uppercase( eclipseState->getIOConfig()->getBaseName() ) )
|
||||
, summary( *eclipseState, eclipseState->getSummaryConfig() )
|
||||
, rft( outputDir.c_str(), baseName.c_str(), es->getIOConfig()->getFMTOUT() )
|
||||
, sim_start_time( es->getSchedule()->posixStartTime() )
|
||||
, output_enabled( eclipseState->getIOConfig()->getOutputEnabled() )
|
||||
, ert_phase_mask( ertPhaseMask( eclipseState->getTableManager() ) )
|
||||
{
|
||||
}
|
||||
|
||||
EclipseWriter::Impl::Impl( std::shared_ptr< const EclipseState > eclipseState,
|
||||
const EclipseGrid& grid_)
|
||||
: es( eclipseState )
|
||||
, grid( grid_ )
|
||||
, outputDir( eclipseState->getIOConfig()->getOutputDir() )
|
||||
, baseName( uppercase( eclipseState->getIOConfig()->getBaseName() ) )
|
||||
, summary( *eclipseState, eclipseState->getSummaryConfig() )
|
||||
, rft( outputDir.c_str(), baseName.c_str(), es->getIOConfig()->getFMTOUT() )
|
||||
, sim_start_time( es->getSchedule()->posixStartTime() )
|
||||
, output_enabled( eclipseState->getIOConfig()->getOutputEnabled() )
|
||||
, ert_phase_mask( ertPhaseMask( eclipseState->getTableManager() ) )
|
||||
{
|
||||
}
|
||||
|
||||
, grid( std::move( grid_ ) )
|
||||
, outputDir( eclipseState.getIOConfig().getOutputDir() )
|
||||
, baseName( uppercase( eclipseState.getIOConfig().getBaseName() ) )
|
||||
, summary( eclipseState, eclipseState.getSummaryConfig() )
|
||||
, rft( outputDir.c_str(), baseName.c_str(), es.getIOConfig().getFMTOUT() )
|
||||
, sim_start_time( es.getSchedule().posixStartTime() )
|
||||
, output_enabled( eclipseState.getIOConfig().getOutputEnabled() )
|
||||
, ert_phase_mask( ertPhaseMask( eclipseState.getTableManager() ) )
|
||||
{}
|
||||
|
||||
void EclipseWriter::Impl::writeINITFile( const data::Solution& simProps, const NNC& nnc) const {
|
||||
const auto& es = *this->es;
|
||||
const auto& es = this->es;
|
||||
const auto& units = es.getUnits();
|
||||
const EclipseGrid& grid = this->grid;
|
||||
const IOConfig& ioConfig = es.cfg().io();
|
||||
@@ -554,13 +538,13 @@ void EclipseWriter::Impl::writeINITFile( const data::Solution& simProps, const N
|
||||
|
||||
|
||||
void EclipseWriter::Impl::writeEGRIDFile( const NNC& nnc ) const {
|
||||
const auto& es = *this->es;
|
||||
const auto& es = this->es;
|
||||
const auto& ioConfig = es.getIOConfig();
|
||||
|
||||
FileName egridFile( this->outputDir,
|
||||
this->baseName,
|
||||
ECL_EGRID_FILE,
|
||||
ioConfig->getFMTOUT() );
|
||||
ioConfig.getFMTOUT() );
|
||||
|
||||
{
|
||||
const EclipseGrid& grid = this->grid;
|
||||
@@ -579,7 +563,7 @@ void EclipseWriter::writeInitAndEgrid(data::Solution simProps, const NNC& nnc) {
|
||||
return;
|
||||
|
||||
{
|
||||
const auto& es = *this->impl->es;
|
||||
const auto& es = this->impl->es;
|
||||
const IOConfig& ioConfig = es.cfg().io();
|
||||
|
||||
simProps.convertFromSI( es.getUnits() );
|
||||
@@ -606,7 +590,7 @@ void EclipseWriter::writeTimeStep(int report_step,
|
||||
|
||||
|
||||
time_t current_posix_time = this->impl->sim_start_time + secs_elapsed;
|
||||
const auto& es = *this->impl->es;
|
||||
const auto& es = this->impl->es;
|
||||
const auto& grid = this->impl->grid;
|
||||
const auto& units = es.getUnits();
|
||||
|
||||
@@ -614,7 +598,7 @@ void EclipseWriter::writeTimeStep(int report_step,
|
||||
|
||||
|
||||
const auto days = units.from_si( UnitSystem::measure::time, secs_elapsed );
|
||||
const auto& schedule = *es.getSchedule();
|
||||
const auto& schedule = es.getSchedule();
|
||||
|
||||
/*
|
||||
This routine can optionally write RFT and/or restart file; to
|
||||
@@ -744,7 +728,7 @@ void EclipseWriter::writeTimeStep(int report_step,
|
||||
this->impl->summary.add_timestep( report_step,
|
||||
secs_elapsed,
|
||||
this->impl->grid,
|
||||
*this->impl->es,
|
||||
this->impl->es,
|
||||
this->impl->regionCells,
|
||||
wells ,
|
||||
cells );
|
||||
@@ -753,8 +737,8 @@ void EclipseWriter::writeTimeStep(int report_step,
|
||||
|
||||
|
||||
|
||||
EclipseWriter::EclipseWriter( std::shared_ptr< const EclipseState > es, EclipseGrid grid)
|
||||
: impl( new Impl( es, std::move(grid) ) )
|
||||
EclipseWriter::EclipseWriter( const EclipseState& es, EclipseGrid grid)
|
||||
: impl( new Impl( es, std::move( grid ) ) )
|
||||
{
|
||||
if( !this->impl->output_enabled )
|
||||
return;
|
||||
@@ -777,7 +761,7 @@ EclipseWriter::EclipseWriter( std::shared_ptr< const EclipseState > es, EclipseG
|
||||
evaluation of region properties.
|
||||
*/
|
||||
{
|
||||
const auto& properties = this->impl->es->get3DProperties();
|
||||
const auto& properties = this->impl->es.get3DProperties();
|
||||
const auto& fipnum = properties.getIntGridProperty("FIPNUM");
|
||||
const auto& region_values = properties.getRegions( "FIPNUM" );
|
||||
|
||||
|
||||
@@ -543,7 +543,7 @@ class Summary::keyword_handlers {
|
||||
};
|
||||
|
||||
Summary::Summary( const EclipseState& st, const SummaryConfig& sum ) :
|
||||
Summary( st, sum, st.getIOConfig()->fullBasePath().c_str() )
|
||||
Summary( st, sum, st.getIOConfig().fullBasePath().c_str() )
|
||||
{}
|
||||
|
||||
Summary::Summary( const EclipseState& st,
|
||||
@@ -558,14 +558,14 @@ Summary::Summary( const EclipseState& st,
|
||||
ecl_sum(
|
||||
ecl_sum_alloc_writer(
|
||||
basename,
|
||||
st.getIOConfig()->getFMTOUT(),
|
||||
st.getIOConfig()->getUNIFOUT(),
|
||||
st.getIOConfig().getFMTOUT(),
|
||||
st.getIOConfig().getUNIFOUT(),
|
||||
":",
|
||||
st.getSchedule()->posixStartTime(),
|
||||
st.getSchedule().posixStartTime(),
|
||||
true,
|
||||
st.getInputGrid()->getNX(),
|
||||
st.getInputGrid()->getNY(),
|
||||
st.getInputGrid()->getNZ()
|
||||
st.getInputGrid().getNX(),
|
||||
st.getInputGrid().getNY(),
|
||||
st.getInputGrid().getNZ()
|
||||
)
|
||||
),
|
||||
handlers( new keyword_handlers() )
|
||||
@@ -605,7 +605,7 @@ void Summary::add_timestep( int report_step,
|
||||
const double duration = secs_elapsed - this->prev_time_elapsed;
|
||||
|
||||
const size_t timestep = report_step;
|
||||
const auto& schedule = *es.getSchedule();
|
||||
const auto& schedule = es.getSchedule();
|
||||
|
||||
for( auto& f : this->handlers->handlers ) {
|
||||
const int num = smspec_node_get_num( f.first );
|
||||
|
||||
@@ -272,10 +272,9 @@ BOOST_AUTO_TEST_CASE(EclipseWriterIntegration) {
|
||||
|
||||
auto write_and_check = [&]( int first = 1, int last = 5 ) {
|
||||
auto deck = Parser().parseString( deckString, ParseContext() );
|
||||
auto es = std::make_shared< EclipseState >( Parser::parse( *deck ) );
|
||||
es->getIOConfig()->setBaseName( "FOO" );
|
||||
|
||||
auto& eclGrid = *es->getInputGrid();
|
||||
auto es = Parser::parse( deck );
|
||||
auto& eclGrid = es.getInputGrid();
|
||||
es.getIOConfig().setBaseName( "FOO" );
|
||||
|
||||
EclipseWriter eclWriter( es, eclGrid );
|
||||
|
||||
@@ -314,7 +313,7 @@ BOOST_AUTO_TEST_CASE(EclipseWriterIntegration) {
|
||||
checkRestartFile( i );
|
||||
}
|
||||
|
||||
checkInitFile( *deck , eGridProps);
|
||||
checkInitFile( deck , eGridProps);
|
||||
checkEgridFile( eclGrid );
|
||||
|
||||
std::ifstream file( "FOO.UNRST", std::ios::binary );
|
||||
|
||||
@@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE(test_RFT) {
|
||||
ERT::TestArea test_area("test_RFT");
|
||||
test_area.copyFile( eclipse_data_filename );
|
||||
|
||||
auto eclipseState = std::make_shared< EclipseState >( Parser::parse( eclipse_data_filename ) );
|
||||
auto eclipseState = Parser::parse( eclipse_data_filename );
|
||||
{
|
||||
/* eclipseWriter is scoped here to ensure it is destroyed after the
|
||||
* file itself has been written, because we're going to reload it
|
||||
@@ -117,11 +117,11 @@ BOOST_AUTO_TEST_CASE(test_RFT) {
|
||||
* written to disk and flushed.
|
||||
*/
|
||||
|
||||
const auto numCells = eclipseState->getInputGrid()->getCartesianSize( );
|
||||
const auto& grid = *eclipseState->getInputGrid();
|
||||
const auto& grid = eclipseState.getInputGrid();
|
||||
const auto numCells = grid.getCartesianSize( );
|
||||
|
||||
EclipseWriter eclipseWriter( eclipseState, grid);
|
||||
time_t start_time = eclipseState->getSchedule()->posixStartTime();
|
||||
time_t start_time = eclipseState.getSchedule().posixStartTime();
|
||||
/* step time read from deck and hard-coded here */
|
||||
time_t step_time = ecl_util_make_date(10, 10, 2008 );
|
||||
|
||||
|
||||
@@ -229,10 +229,9 @@ first_sim(test_work_area_type * test_area) {
|
||||
std::string eclipse_data_filename = "FIRST_SIM.DATA";
|
||||
test_work_area_copy_file(test_area, eclipse_data_filename.c_str());
|
||||
|
||||
auto eclipseState = std::make_shared< EclipseState >(
|
||||
Parser::parse( eclipse_data_filename ) );
|
||||
auto eclipseState = Parser::parse( eclipse_data_filename );
|
||||
|
||||
const auto& grid = *eclipseState->getInputGrid();
|
||||
const auto& grid = eclipseState.getInputGrid();
|
||||
auto num_cells = grid.getNX() * grid.getNY() * grid.getNZ();
|
||||
|
||||
EclipseWriter eclWriter( eclipseState, grid);
|
||||
@@ -253,7 +252,7 @@ first_sim(test_work_area_type * test_area) {
|
||||
std::pair< data::Solution, data::Wells > second_sim() {
|
||||
auto eclipseState = Parser::parseData( input );
|
||||
|
||||
const auto& grid = *eclipseState.getInputGrid();
|
||||
const auto& grid = eclipseState.getInputGrid();
|
||||
auto num_cells = grid.getNX() * grid.getNY() * grid.getNZ();
|
||||
|
||||
return init_from_restart_file( eclipseState, num_cells );
|
||||
|
||||
@@ -86,16 +86,16 @@ BOOST_AUTO_TEST_CASE(Create2)
|
||||
BOOST_AUTO_TEST_CASE(UNITS) {
|
||||
std::vector<double> data(100,1);
|
||||
data::Solution c;
|
||||
auto metric = std::unique_ptr<UnitSystem>( UnitSystem::newMETRIC() );
|
||||
auto metric = UnitSystem::newMETRIC();
|
||||
|
||||
c.insert("NAME", UnitSystem::measure::pressure, data , data::TargetType::RESTART_SOLUTION);
|
||||
|
||||
double si0 = c.data("NAME")[0];
|
||||
c.convertFromSI( *metric );
|
||||
c.convertFromSI( metric );
|
||||
double metric0 = c.data("NAME")[0];
|
||||
c.convertFromSI( *metric );
|
||||
c.convertFromSI( metric );
|
||||
BOOST_CHECK_EQUAL( metric0 , c.data("NAME")[0] );
|
||||
c.convertToSI( *metric );
|
||||
c.convertToSI( metric );
|
||||
BOOST_CHECK_EQUAL( si0 , c.data("NAME")[0] );
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ ERT::ert_unique_ptr< ecl_sum_type, ecl_sum_free > readsum( const std::string& ba
|
||||
}
|
||||
|
||||
struct setup {
|
||||
std::shared_ptr< Deck > deck;
|
||||
Deck deck;
|
||||
EclipseState es;
|
||||
SummaryConfig config;
|
||||
const EclipseGrid& grid;
|
||||
@@ -172,12 +172,13 @@ struct setup {
|
||||
|
||||
setup( const std::string& fname , const ParseContext& parseContext = ParseContext( )) :
|
||||
deck( Parser().parseFile( path, parseContext ) ),
|
||||
es( *deck, ParseContext() ),
|
||||
config( *deck, es , parseContext ),
|
||||
grid( *es.getInputGrid() ),
|
||||
es( deck, ParseContext() ),
|
||||
config( deck, es, parseContext ),
|
||||
grid( es.getInputGrid() ),
|
||||
wells( result_wells() ),
|
||||
name( fname ),
|
||||
ta( ERT::TestArea("test_summary") )
|
||||
ta( ERT::TestArea("test_summary") ),
|
||||
solution( make_solution( es.getInputGrid() ) )
|
||||
{
|
||||
const auto& properties = es.get3DProperties();
|
||||
const auto& fipnum = properties.getIntGridProperty("FIPNUM");
|
||||
@@ -185,8 +186,6 @@ struct setup {
|
||||
|
||||
for (auto region_id : region_values)
|
||||
cells.emplace( region_id , fipnum.cellsEqual( region_id , grid ));
|
||||
|
||||
solution = make_solution( *es.getInputGrid());
|
||||
}
|
||||
|
||||
};
|
||||
@@ -598,7 +597,7 @@ BOOST_AUTO_TEST_CASE(region_vars) {
|
||||
BOOST_CHECK( ecl_sum_has_general_var( resp , "RPR:1"));
|
||||
BOOST_CHECK( ecl_sum_has_general_var( resp , "RPR:10"));
|
||||
BOOST_CHECK( !ecl_sum_has_general_var( resp , "RPR:11"));
|
||||
UnitSystem units( UnitSystem::UNIT_TYPE_METRIC );
|
||||
UnitSystem units( UnitSystem::UnitType::UNIT_TYPE_METRIC );
|
||||
|
||||
for (size_t r=1; r <= 10; r++) {
|
||||
std::string key = "RPR:" + std::to_string( r );
|
||||
|
||||
@@ -47,17 +47,17 @@
|
||||
using namespace Opm;
|
||||
|
||||
void verifyWellState(const std::string& rst_filename,
|
||||
EclipseGridConstPtr ecl_grid,
|
||||
ScheduleConstPtr schedule) {
|
||||
const EclipseGrid& ecl_grid,
|
||||
const Schedule& schedule) {
|
||||
|
||||
well_info_type* well_info = well_info_alloc(ecl_grid->c_ptr());
|
||||
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_EQUAL( numwells, schedule->numWells() );
|
||||
BOOST_CHECK_EQUAL( numwells, schedule.numWells() );
|
||||
|
||||
auto wells = schedule->getWells();
|
||||
auto wells = schedule.getWells();
|
||||
|
||||
for (int i = 0; i < numwells; ++i) {
|
||||
|
||||
@@ -111,19 +111,19 @@ void verifyWellState(const std::string& rst_filename,
|
||||
size_t num_wellconnections = well_conn_collection_get_size(well_connections);
|
||||
|
||||
int report_nr = well_state_get_report_nr(well_state);
|
||||
auto completions_set = well->getCompletions((size_t)report_nr);
|
||||
const auto& completions_set = well->getCompletions((size_t)report_nr);
|
||||
|
||||
BOOST_CHECK_EQUAL(num_wellconnections, completions_set->size());
|
||||
BOOST_CHECK_EQUAL(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);
|
||||
|
||||
Opm::CompletionConstPtr completion = completions_set->get(k);
|
||||
const auto& completion = completions_set.get(k);
|
||||
|
||||
BOOST_CHECK_EQUAL(well_conn_get_i(well_connection), completion->getI());
|
||||
BOOST_CHECK_EQUAL(well_conn_get_j(well_connection), completion->getJ());
|
||||
BOOST_CHECK_EQUAL(well_conn_get_k(well_connection), completion->getK());
|
||||
BOOST_CHECK_EQUAL(well_conn_get_i(well_connection), completion.getI());
|
||||
BOOST_CHECK_EQUAL(well_conn_get_j(well_connection), completion.getJ());
|
||||
BOOST_CHECK_EQUAL(well_conn_get_k(well_connection), completion.getK());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,11 +139,10 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo) {
|
||||
test_work_area_copy_file(test_area, eclipse_data_filename.c_str());
|
||||
|
||||
auto es = Parser::parse( eclipse_data_filename, ParseContext() );
|
||||
auto eclipseState = std::make_shared< EclipseState >( es );
|
||||
const auto num_cells = eclipseState->getInputGrid()->getCartesianSize();
|
||||
EclipseWriter eclipseWriter( eclipseState, *eclipseState->getInputGrid());
|
||||
const auto num_cells = es.getInputGrid().getCartesianSize();
|
||||
EclipseWriter eclipseWriter( es, es.getInputGrid() );
|
||||
|
||||
int countTimeStep = eclipseState->getSchedule()->getTimeMap()->numTimesteps();
|
||||
int countTimeStep = es.getSchedule().getTimeMap().numTimesteps();
|
||||
|
||||
data::Solution solution;
|
||||
solution.insert( "PRESSURE",UnitSystem::measure::pressure , std::vector< double >( num_cells, 1 ) , data::TargetType::RESTART_SOLUTION);
|
||||
@@ -165,7 +164,7 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo) {
|
||||
wells );
|
||||
}
|
||||
|
||||
verifyWellState(eclipse_restart_filename, eclipseState->getInputGrid(), eclipseState->getSchedule());
|
||||
verifyWellState(eclipse_restart_filename, es.getInputGrid(), es.getSchedule());
|
||||
|
||||
test_work_area_free(test_area);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user