Update GDFILE handling to account for out-of-cwd
Make sure path to GDFILE is correct
This commit is contained in:
@@ -65,7 +65,7 @@ namespace Opm {
|
||||
|
||||
private:
|
||||
void init(const DeckKeyword& keyword);
|
||||
void binary_init(const DeckKeyword& gdfile);
|
||||
void binary_init(const Deck& deck);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -297,8 +297,10 @@ 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);
|
||||
const DeckKeyword& gdfile_kw = deck.getKeyword("GDFILE");
|
||||
const std::string& gdfile_arg = gdfile_kw.getRecord(0).getItem("filename").get<std::string>(0);
|
||||
std::string filename = deck.makeDeckPath(gdfile_arg);
|
||||
|
||||
ecl_grid_type * grid_ptr = ecl_grid_load_case__( filename.c_str(), false);
|
||||
if (grid_ptr)
|
||||
this->m_grid.reset( grid_ptr );
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Opm {
|
||||
else if (deck.hasKeyword("DIMENS"))
|
||||
init(deck.getKeyword("DIMENS"));
|
||||
else if (deck.hasKeyword("GDFILE"))
|
||||
binary_init(deck.getKeyword("GDFILE"));
|
||||
binary_init(deck);
|
||||
else
|
||||
throw std::invalid_argument("Must have either SPECGRID or DIMENS to indicate grid dimensions");
|
||||
}
|
||||
@@ -137,8 +137,10 @@ 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);
|
||||
void GridDims::binary_init(const Deck& deck) {
|
||||
const DeckKeyword& gdfile_kw = deck.getKeyword("GDFILE");
|
||||
const std::string& gdfile_arg = gdfile_kw.getRecord(0).getItem("filename").get<std::string>(0);
|
||||
std::string filename = deck.makeDeckPath(gdfile_arg);
|
||||
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);
|
||||
@@ -146,7 +148,7 @@ namespace Opm {
|
||||
m_ny = dims->ny;
|
||||
m_nz = dims->nz;
|
||||
} else
|
||||
throw std::invalid_argument("Could not determine grid dimensions from " + filename);
|
||||
throw std::invalid_argument("Could not determine grid dimensions from: " + filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <cstdio>
|
||||
#include <numeric>
|
||||
|
||||
|
||||
#define BOOST_TEST_MODULE EclipseGridTests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
@@ -792,15 +793,21 @@ BOOST_AUTO_TEST_CASE(GDFILE) {
|
||||
const char* gdfile_deck =
|
||||
"GRID\n"
|
||||
"GDFILE\n"
|
||||
"CASE.EGRID /\n"
|
||||
"'grid/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);
|
||||
util_mkdir_p("ecl/grid");
|
||||
grid1.save("ecl/grid/CASE.EGRID", Opm::UnitSystem::UnitType::UNIT_TYPE_METRIC);
|
||||
{
|
||||
FILE * stream = fopen("ecl/DECK.DATA", "w");
|
||||
fputs(gdfile_deck, stream);
|
||||
fclose(stream);
|
||||
}
|
||||
{
|
||||
Opm::Parser parser;
|
||||
Opm::EclipseGrid grid2(parser.parseString(gdfile_deck, Opm::ParseContext() ));
|
||||
Opm::EclipseGrid grid2(parser.parseFile("ecl/DECK.DATA", Opm::ParseContext() ));
|
||||
BOOST_CHECK(grid1.equal(grid2));
|
||||
}
|
||||
test_work_area_free( work_area );
|
||||
|
||||
Reference in New Issue
Block a user