Add support for GDFILE keyword
This commit is contained in:
@@ -77,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&);
|
||||
@@ -203,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 ,
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#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>
|
||||
@@ -205,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.");
|
||||
}
|
||||
@@ -293,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 );
|
||||
@@ -539,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 ))
|
||||
|
||||
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user