commit
6ea7a1796d
@ -38,6 +38,7 @@ namespace Opm {
|
||||
|
||||
class Deck;
|
||||
class ZcornMapper;
|
||||
class NNC;
|
||||
|
||||
/**
|
||||
About cell information and dimension: The actual grid
|
||||
@ -76,6 +77,8 @@ namespace Opm {
|
||||
/// explicitly. If a null pointer is passed, every cell is active.
|
||||
EclipseGrid(const Deck& deck, const int * actnum = nullptr);
|
||||
|
||||
|
||||
static bool hasGDFILE(const Deck& deck);
|
||||
static bool hasCylindricalKeywords(const Deck& deck);
|
||||
static bool hasCornerPointKeywords(const Deck&);
|
||||
static bool hasCartesianKeywords(const Deck&);
|
||||
@ -85,6 +88,8 @@ namespace Opm {
|
||||
size_t activeIndex(size_t i, size_t j, size_t k) const;
|
||||
size_t activeIndex(size_t globalIndex) const;
|
||||
|
||||
void save(const std::string& filename, UnitSystem::UnitType output_units) const;
|
||||
void addNNC(const NNC& nnc);
|
||||
/*
|
||||
Observe that the there is a getGlobalIndex(i,j,k)
|
||||
implementation in the base class. This method - translating
|
||||
@ -200,6 +205,7 @@ namespace Opm {
|
||||
ert_ptr( ecl_grid_alloc_copy( src.get() ) ) {}
|
||||
};
|
||||
grid_ptr m_grid;
|
||||
void initBinaryGrid(const Deck& deck);
|
||||
|
||||
void initCornerPointGrid(const std::array<int,3>& dims ,
|
||||
const std::vector<double>& coord ,
|
||||
|
@ -65,6 +65,7 @@ namespace Opm {
|
||||
|
||||
private:
|
||||
void init(const DeckKeyword& keyword);
|
||||
void binary_init(const DeckKeyword& gdfile);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -97,6 +97,7 @@ namespace Opm {
|
||||
void to_si( measure, std::vector<double>& ) const;
|
||||
const char* name( measure ) const;
|
||||
|
||||
static ert_ecl_unit_enum ecl_units(UnitType opm_unit);
|
||||
static UnitSystem newMETRIC();
|
||||
static UnitSystem newFIELD();
|
||||
static UnitSystem newLAB();
|
||||
|
@ -205,7 +205,7 @@ class EclipseIO::Impl {
|
||||
public:
|
||||
Impl( const EclipseState&, EclipseGrid, const Schedule&, const SummaryConfig& );
|
||||
void writeINITFile( const data::Solution& simProps, std::map<std::string, std::vector<int> > int_data, const NNC& nnc) const;
|
||||
void writeEGRIDFile( const NNC& nnc ) const;
|
||||
void writeEGRIDFile( const NNC& nnc );
|
||||
|
||||
const EclipseState& es;
|
||||
EclipseGrid grid;
|
||||
@ -374,7 +374,7 @@ void EclipseIO::Impl::writeINITFile( const data::Solution& simProps, std::map<st
|
||||
}
|
||||
|
||||
|
||||
void EclipseIO::Impl::writeEGRIDFile( const NNC& nnc ) const {
|
||||
void EclipseIO::Impl::writeEGRIDFile( const NNC& nnc ) {
|
||||
const auto& ioConfig = this->es.getIOConfig();
|
||||
|
||||
std::string egridFile( ERT::EclFilename( this->outputDir,
|
||||
@ -382,14 +382,8 @@ void EclipseIO::Impl::writeEGRIDFile( const NNC& nnc ) const {
|
||||
ECL_EGRID_FILE,
|
||||
ioConfig.getFMTOUT() ));
|
||||
|
||||
{
|
||||
int idx = 0;
|
||||
auto* ecl_grid = const_cast< ecl_grid_type* >( this->grid.c_ptr() );
|
||||
for (const NNCdata& n : nnc.nncdata())
|
||||
ecl_grid_add_self_nnc( ecl_grid, n.cell1, n.cell2, idx++);
|
||||
|
||||
ecl_grid_fwrite_EGRID2(ecl_grid, egridFile.c_str(), this->es.getDeckUnitSystem().getEclType() );
|
||||
}
|
||||
this->grid.addNNC( nnc );
|
||||
this->grid.save( egridFile, this->es.getDeckUnitSystem().getType());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -32,12 +32,14 @@
|
||||
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/NNC.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/A.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/C.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/D.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/G.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/I.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/M.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/P.hpp>
|
||||
@ -54,10 +56,10 @@ namespace Opm {
|
||||
|
||||
|
||||
EclipseGrid::EclipseGrid(std::array<int, 3>& dims ,
|
||||
const std::vector<double>& coord ,
|
||||
const std::vector<double>& zcorn ,
|
||||
const int * actnum,
|
||||
const double * mapaxes)
|
||||
const std::vector<double>& coord ,
|
||||
const std::vector<double>& zcorn ,
|
||||
const int * actnum,
|
||||
const double * mapaxes)
|
||||
: GridDims(dims),
|
||||
m_minpvValue(0),
|
||||
m_minpvMode(MinpvMode::ModeEnum::Inactive),
|
||||
@ -204,6 +206,8 @@ namespace Opm {
|
||||
initCornerPointGrid(dims , deck);
|
||||
} else if (hasCartesianKeywords(deck)) {
|
||||
initCartesianGrid(dims , deck);
|
||||
} else if (hasGDFILE(deck)) {
|
||||
initBinaryGrid(deck);
|
||||
} else {
|
||||
throw std::invalid_argument("EclipseGrid needs cornerpoint or cartesian keywords.");
|
||||
}
|
||||
@ -292,6 +296,16 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
void EclipseGrid::initBinaryGrid(const Deck& deck) {
|
||||
const auto& gdfile_record = deck.getKeyword<ParserKeywords::GDFILE>().getRecord(0);
|
||||
const std::string& filename = gdfile_record.getItem("filename").get<std::string>(0);
|
||||
ecl_grid_type * grid_ptr = ecl_grid_load_case__( filename.c_str(), false);
|
||||
if (grid_ptr)
|
||||
this->m_grid.reset( grid_ptr );
|
||||
else
|
||||
throw std::invalid_argument("Failed to load grid from: " + filename);
|
||||
}
|
||||
|
||||
void EclipseGrid::initCartesianGrid(const std::array<int, 3>& dims , const Deck& deck) {
|
||||
if (hasDVDEPTHZKeywords( deck ))
|
||||
initDVDEPTHZGrid( dims , deck );
|
||||
@ -538,6 +552,9 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
bool EclipseGrid::hasGDFILE(const Deck& deck) {
|
||||
return deck.hasKeyword<ParserKeywords::GDFILE>();
|
||||
}
|
||||
|
||||
bool EclipseGrid::hasCartesianKeywords(const Deck& deck) {
|
||||
if (hasDVDEPTHZKeywords( deck ))
|
||||
@ -887,6 +904,20 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
void EclipseGrid::addNNC(const NNC& nnc) {
|
||||
int idx = 0;
|
||||
auto* ecl_grid = const_cast< ecl_grid_type* >( this->c_ptr() );
|
||||
for (const NNCdata& n : nnc.nncdata())
|
||||
ecl_grid_add_self_nnc( ecl_grid, n.cell1, n.cell2, idx++);
|
||||
}
|
||||
|
||||
|
||||
void EclipseGrid::save(const std::string& filename, UnitSystem::UnitType output_units) const {
|
||||
auto* ecl_grid = const_cast< ecl_grid_type* >( this->c_ptr() );
|
||||
ecl_grid_fwrite_EGRID2(ecl_grid, filename.c_str(), UnitSystem::ecl_units(output_units));
|
||||
}
|
||||
|
||||
|
||||
|
||||
const std::vector<int>& EclipseGrid::getActiveMap() const {
|
||||
if( !this->activeMap.empty() ) return this->activeMap;
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
#include <ert/ecl/ecl_grid_dims.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
||||
@ -46,6 +48,8 @@ namespace Opm {
|
||||
init(deck.getKeyword("SPECGRID"));
|
||||
else if (deck.hasKeyword("DIMENS"))
|
||||
init(deck.getKeyword("DIMENS"));
|
||||
else if (deck.hasKeyword("GDFILE"))
|
||||
binary_init(deck.getKeyword("GDFILE"));
|
||||
else
|
||||
throw std::invalid_argument("Must have either SPECGRID or DIMENS to indicate grid dimensions");
|
||||
}
|
||||
@ -133,4 +137,16 @@ namespace Opm {
|
||||
m_nz = dims[2];
|
||||
}
|
||||
|
||||
void GridDims::binary_init(const DeckKeyword& gdfile) {
|
||||
const std::string& filename = gdfile.getRecord(0).getItem("filename").get<std::string>(0);
|
||||
ecl_grid_dims_type * grid_dims = ecl_grid_dims_alloc( filename.c_str(), nullptr );
|
||||
if (grid_dims) {
|
||||
const auto& dims = ecl_grid_dims_iget_dims(grid_dims, 0);
|
||||
m_nx = dims->nx;
|
||||
m_ny = dims->ny;
|
||||
m_nz = dims->nz;
|
||||
} else
|
||||
throw std::invalid_argument("Could not determine grid dimensions from " + filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -797,19 +797,24 @@ namespace {
|
||||
}
|
||||
|
||||
|
||||
ert_ecl_unit_enum UnitSystem::getEclType() const {
|
||||
switch ( m_unittype ) {
|
||||
case UnitType::UNIT_TYPE_METRIC: return ECL_METRIC_UNITS;
|
||||
case UnitType::UNIT_TYPE_FIELD: return ECL_FIELD_UNITS;
|
||||
case UnitType::UNIT_TYPE_LAB: return ECL_LAB_UNITS;
|
||||
case UnitType::UNIT_TYPE_PVT_M: return ECL_PVT_M_UNITS;
|
||||
case UnitType::UNIT_TYPE_INPUT: throw std::runtime_error("UNIT_TYPE_INPUT has no counterpart in the ert_ecl_unit_enum type.");
|
||||
ert_ecl_unit_enum UnitSystem::ecl_units(UnitSystem::UnitType opm_type) {
|
||||
switch ( opm_type ) {
|
||||
case UnitType::UNIT_TYPE_METRIC: return ECL_METRIC_UNITS;
|
||||
case UnitType::UNIT_TYPE_FIELD: return ECL_FIELD_UNITS;
|
||||
case UnitType::UNIT_TYPE_LAB: return ECL_LAB_UNITS;
|
||||
case UnitType::UNIT_TYPE_PVT_M: return ECL_PVT_M_UNITS;
|
||||
case UnitType::UNIT_TYPE_INPUT: throw std::runtime_error("UNIT_TYPE_INPUT has no counterpart in the ert_ecl_unit_enum type.");
|
||||
default:
|
||||
throw std::runtime_error("What has happened here?");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ert_ecl_unit_enum UnitSystem::getEclType() const {
|
||||
return UnitSystem::ecl_units( this->m_unittype );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Dimension UnitSystem::parseFactor(const std::string& dimension) const {
|
||||
std::vector<std::string> dimensionList;
|
||||
|
@ -0,0 +1,3 @@
|
||||
{"name" : "GDFILE" , "sections" : ["GRID"], "size" : 1 , "items" : [
|
||||
{"name" : "filename" , "value_type" : "STRING"},
|
||||
{"name" : "formatted" , "value_type" : "STRING", "default" : "U"}]}
|
@ -108,6 +108,7 @@ set( keywords
|
||||
000_Eclipse100/G/GAS
|
||||
000_Eclipse100/G/GCONINJE
|
||||
000_Eclipse100/G/GCONPROD
|
||||
000_Eclipse100/G/GDFILE
|
||||
000_Eclipse100/G/GDORIENT
|
||||
000_Eclipse100/G/GECON
|
||||
000_Eclipse100/G/GEFAC
|
||||
|
@ -27,6 +27,9 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include <ert/util/test_work_area.h>
|
||||
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Section.hpp>
|
||||
@ -785,7 +788,23 @@ BOOST_AUTO_TEST_CASE(ConstructorNORUNSPEC) {
|
||||
BOOST_CHECK(grid1.equal( grid2 ));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(GDFILE) {
|
||||
const char* gdfile_deck =
|
||||
"GRID\n"
|
||||
"GDFILE\n"
|
||||
"CASE.EGRID /\n"
|
||||
"\n";
|
||||
|
||||
Opm::EclipseGrid grid1(createCPDeck());
|
||||
test_work_area_type * work_area = test_work_area_alloc("GDFILE");
|
||||
grid1.save("CASE.EGRID", Opm::UnitSystem::UnitType::UNIT_TYPE_METRIC);
|
||||
{
|
||||
Opm::Parser parser;
|
||||
Opm::EclipseGrid grid2(parser.parseString(gdfile_deck, Opm::ParseContext() ));
|
||||
BOOST_CHECK(grid1.equal(grid2));
|
||||
}
|
||||
test_work_area_free( work_area );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ConstructorNoSections) {
|
||||
const char* deckData =
|
||||
|
Loading…
Reference in New Issue
Block a user