Split EclipseGrid in dimensions and cell info.

In many cases the only required information in an EclipseGrid instance
is the cartesian dimensions. To facilitate simpler testing - and not
have to create a full dummy grid the dimensions have been internalized
as a separate nx,ny,nz triplet. With this commit it is possible to
instantiate a grid with only dimensions, and no underlying ecl_grid_type
pointer.
This commit is contained in:
Joakim Hove
2014-11-09 23:31:53 +01:00
parent a7ba8af558
commit 39bca17ce0
3 changed files with 122 additions and 12 deletions

View File

@@ -65,6 +65,23 @@ static Opm::DeckPtr createDeckHeaders() {
}
static Opm::DeckPtr createDeckMissingDIMS() {
const char *deckData =
"RUNSPEC\n"
"\n"
"GRID\n"
"EDIT\n"
"\n";
Opm::ParserPtr parser(new Opm::Parser());
return parser->parseString(deckData) ;
}
BOOST_AUTO_TEST_CASE(MissingDimsThrows) {
Opm::DeckPtr deck = createDeckMissingDIMS();
BOOST_CHECK_THROW( new Opm::EclipseGrid( deck ) , std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(HasGridKeywords) {
Opm::DeckPtr deck = createDeckHeaders();
@@ -72,6 +89,18 @@ BOOST_AUTO_TEST_CASE(HasGridKeywords) {
BOOST_CHECK( !Opm::EclipseGrid::hasCartesianKeywords( deck ));
}
BOOST_AUTO_TEST_CASE(CreateGridNoCells) {
Opm::DeckPtr deck = createDeckHeaders();
Opm::EclipseGrid grid( deck );
BOOST_CHECK_EQUAL( 10 , grid.getNX());
BOOST_CHECK_EQUAL( 10 , grid.getNY());
BOOST_CHECK_EQUAL( 10 , grid.getNZ());
BOOST_CHECK_EQUAL( 1000 , grid.getCartesianSize());
}
static Opm::DeckPtr createCPDeck() {
const char *deckData =
"RUNSPEC\n"
@@ -228,6 +257,17 @@ static Opm::DeckPtr createCARTInvalidDeck() {
return parser->parseString(deckData) ;
}
BOOST_AUTO_TEST_CASE(CREATE_SIMPLE) {
Opm::EclipseGrid grid(10,20,30);
BOOST_CHECK_EQUAL( grid.getNX() , 10 );
BOOST_CHECK_EQUAL( grid.getNY() , 20 );
BOOST_CHECK_EQUAL( grid.getNZ() , 30 );
BOOST_CHECK_EQUAL( grid.getCartesianSize() , 6000 );
BOOST_CHECK_EQUAL( false , grid.hasCellInfo() );
}
BOOST_AUTO_TEST_CASE(DEPTHZ_EQUAL_TOPS) {
Opm::DeckPtr deck1 = createCARTDeck();
Opm::DeckPtr deck2 = createCARTDeckDEPTHZ();
@@ -306,7 +346,8 @@ BOOST_AUTO_TEST_CASE(HasINVALIDCartKeywords) {
BOOST_AUTO_TEST_CASE(CreateMissingGRID_throws) {
Opm::DeckPtr deck = createDeckHeaders();
BOOST_CHECK_THROW(new Opm::EclipseGrid( deck ) , std::invalid_argument);
Opm::EclipseGrid grid( deck );
BOOST_CHECK_EQUAL( false , grid.hasCellInfo() );
}
@@ -366,7 +407,8 @@ static Opm::DeckPtr createInvalidDXYZCARTDeckDEPTHZ() {
BOOST_AUTO_TEST_CASE(CreateCartesianGRIDDEPTHZ) {
Opm::DeckPtr deck = createInvalidDXYZCARTDeckDEPTHZ();
BOOST_CHECK_THROW(new Opm::EclipseGrid( deck ) , std::invalid_argument);
Opm::EclipseGrid grid( deck );
BOOST_CHECK_EQUAL( false , grid.hasCellInfo() );
}