Added new EclipseGrid constructor

The new EclipseGrid constructor EclipseGrid(nx,ny,nz , GridSection)
allows the construction of a GRID without the RUNSPEC section.
This commit is contained in:
Joakim Hove
2014-08-19 08:25:10 +02:00
parent 39d43158de
commit c06e1bebbf
3 changed files with 53 additions and 10 deletions

View File

@@ -55,17 +55,29 @@ namespace Opm {
record->getItem("NY")->getInt(0) ,
record->getItem("NZ")->getInt(0) };
if (hasCornerPointKeywords(gridSection)) {
initCornerPointGrid(dims , gridSection);
} else if (hasCartesianKeywords(gridSection)) {
initCartesianGrid(dims , gridSection);
} else
throw std::invalid_argument("The GRID section must have COORD / ZCORN or D?? + TOPS keywords");
initGrid( dims , gridSection );
} else
throw std::invalid_argument("The RUNSPEC section must have the DIMENS keyword with grid dimensions");
}
EclipseGrid::EclipseGrid(int nx, int ny , int nz , std::shared_ptr<const GRIDSection> gridSection) {
std::vector<int> dims = {nx , ny , nz};
initGrid( dims , gridSection );
}
void EclipseGrid::initGrid( const std::vector<int>& dims , std::shared_ptr<const GRIDSection> gridSection ) {
if (hasCornerPointKeywords(gridSection)) {
initCornerPointGrid(dims , gridSection);
} else if (hasCartesianKeywords(gridSection)) {
initCartesianGrid(dims , gridSection);
} else
throw std::invalid_argument("The GRID section must have COORD / ZCORN or D?? + TOPS keywords");
}
bool EclipseGrid::equal(const EclipseGrid& other) const {
return ecl_grid_compare( m_grid.get() , other.m_grid.get() , true , false , false );
}

View File

@@ -34,6 +34,7 @@ namespace Opm {
EclipseGrid(const std::string& filename);
EclipseGrid(const ecl_grid_type * src_ptr);
EclipseGrid(std::shared_ptr<const RUNSPECSection> runspecSection, std::shared_ptr<const GRIDSection> gridSection);
EclipseGrid(int nx, int ny , int nz , std::shared_ptr<const GRIDSection> gridSection);
static bool hasCornerPointKeywords(std::shared_ptr<const GRIDSection> gridSection);
@@ -67,6 +68,7 @@ namespace Opm {
void assertCornerPointKeywords( const std::vector<int>& dims , std::shared_ptr<const GRIDSection> gridSection ) const ;
void initDTOPSGrid(const std::vector<int>& dims , std::shared_ptr<const GRIDSection> gridSection);
void initDVDEPTHZGrid(const std::vector<int>& dims , std::shared_ptr<const GRIDSection> gridSection);
void initGrid( const std::vector<int>& dims , std::shared_ptr<const GRIDSection> gridSection );
static bool hasDVDEPTHZKeywords(std::shared_ptr<const GRIDSection> gridSection);
static bool hasDTOPSKeywords(std::shared_ptr<const GRIDSection> gridSection);
static void assertVectorSize(const std::vector<double>& vector , size_t expectedSize , const std::string& msg);

View File

@@ -83,9 +83,11 @@ static Opm::DeckPtr createCPDeck() {
" 10 10 10 /\n"
"GRID\n"
"COORD\n"
"1000*0.25 /\n"
"ZCORN\n"
"1000*0.25 /\n"
" 726*1 / \n"
"ZCORN \n"
" 8000*1 / \n"
"ACTNUM \n"
" 1000*1 / \n"
"EDIT\n"
"\n";
@@ -571,3 +573,30 @@ BOOST_AUTO_TEST_CASE(Fwrite) {
remove("TEST.EGRID");
}
BOOST_AUTO_TEST_CASE(ConstructorNORUNSPEC) {
const char *deckData =
"GRID\n"
"COORD\n"
" 726*1 / \n"
"ZCORN \n"
" 8000*1 / \n"
"ACTNUM \n"
" 1000*1 / \n"
"EDIT\n"
"\n";
Opm::ParserPtr parser(new Opm::Parser());
Opm::DeckConstPtr deck1 = parser->parseString(deckData) ;
Opm::DeckConstPtr deck2 = createCPDeck();
std::shared_ptr<Opm::GRIDSection> gridSection1(new Opm::GRIDSection(deck1) );
std::shared_ptr<Opm::GRIDSection> gridSection2(new Opm::GRIDSection(deck2) );
std::shared_ptr<Opm::RUNSPECSection> runspecSection2(new Opm::RUNSPECSection(deck2) );
Opm::EclipseGrid grid1(10,10,10 , gridSection1 );
Opm::EclipseGrid grid2(runspecSection2 , gridSection2 );
BOOST_CHECK(grid1.equal( grid2 ));
}