diff --git a/opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp b/opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp index 5a12349c3..caa56d0a6 100644 --- a/opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp +++ b/opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp @@ -80,6 +80,8 @@ namespace Opm { explicit EclipseGrid(const Deck& deck, const int * actnum = nullptr); static bool hasGDFILE(const Deck& deck); + static bool hasRADIAL(const Deck& deck); + static bool hasSPIDER(const Deck& deck); static bool hasCylindricalKeywords(const Deck& deck); static bool hasCornerPointKeywords(const Deck&); static bool hasCartesianKeywords(const Deck&); diff --git a/src/opm/input/eclipse/EclipseState/Grid/EclipseGrid.cpp b/src/opm/input/eclipse/EclipseState/Grid/EclipseGrid.cpp index 5905df8e2..190073a73 100644 --- a/src/opm/input/eclipse/EclipseState/Grid/EclipseGrid.cpp +++ b/src/opm/input/eclipse/EclipseState/Grid/EclipseGrid.cpp @@ -61,6 +61,7 @@ #include #include #include +#include #include @@ -332,22 +333,59 @@ EclipseGrid::EclipseGrid(const Deck& deck, const int * actnum) return this->m_circle; } + void EclipseGrid::initGrid(const Deck& deck, const int* actnum) { - if (deck.hasKeyword()) { - initCylindricalGrid(deck ); - } else if (deck.hasKeyword()) { - initSpiderwebGrid(deck ); - } else { - if (hasCornerPointKeywords(deck)) { - initCornerPointGrid(deck); - } else if (hasCartesianKeywords(deck)) { - initCartesianGrid(deck); - } else if (hasGDFILE(deck)) { - initBinaryGrid(deck); - } else { - throw std::invalid_argument("EclipseGrid needs cornerpoint or cartesian keywords."); + const std::map grid_keyword_messages = { + {"COORD", "COORD with ZCORN creates a corner-point grid"}, + {"DEPTHZ", "DEPTHZ with DXV, DYV, DZX creates a cartesian grid"}, + {"TOPS", "TOPS with DX/DXV, DY/DYV, DX/DZX creates a cartesian grid"}, + {"RADIAL", "RADIAL creates a cylindrical grid"}, + {"SPIDER", "SPIDER creates a spider grid"}, + {"GDFILE", "GDFILE reads a grid from file"} + }; + std::vector grid_keywords_found; + + if (hasCornerPointKeywords(deck)) { + grid_keywords_found.push_back("COORD"); + } else if (hasDVDEPTHZKeywords(deck)) { + grid_keywords_found.push_back("DEPTHZ"); + } else if (hasDTOPSKeywords(deck)) { + grid_keywords_found.push_back("TOPS"); + } else if (hasRADIAL(deck)) { + grid_keywords_found.push_back("RADIAL"); + } else if (hasSPIDER(deck)) { + grid_keywords_found.push_back("SPIDER"); + } else if (hasGDFILE(deck)) { + grid_keywords_found.push_back("GDFILE"); + } + + if (grid_keywords_found.size() == 0) { + std::string message = "The grid must be specified using one of these options:"; + for (const auto& item: grid_keyword_messages) { + message += "\n " + item.second; } + throw std::invalid_argument(message); + } + + if (grid_keywords_found.size() > 1) { + std::string message = "The specification of the grid is ambiguous:"; + for (const auto& item: grid_keywords_found) { + message += "\n " + grid_keyword_messages.at(item); + } + throw std::invalid_argument(message); + } + + if (grid_keywords_found[0] == "COORD") { + initCornerPointGrid(deck); + } else if (grid_keywords_found[0] == "DEPTHZ" || grid_keywords_found[0] == "TOPS") { + initCartesianGrid(deck); + } else if (grid_keywords_found[0] == "RADIAL") { + initCylindricalGrid(deck ); + } else if (grid_keywords_found[0] == "SPIDER") { + initSpiderwebGrid(deck ); + } else if (grid_keywords_found[0] == "GDFILE") { + initBinaryGrid(deck); } if (deck.hasKeyword()) { @@ -1230,13 +1268,17 @@ EclipseGrid::EclipseGrid(const Deck& deck, const int * actnum) return deck.hasKeyword(); } - bool EclipseGrid::hasCartesianKeywords(const Deck& deck) { - if (hasDVDEPTHZKeywords( deck )) - return true; - else - return hasDTOPSKeywords(deck); + + bool EclipseGrid::hasRADIAL(const Deck& deck) { + return deck.hasKeyword(); } + + bool EclipseGrid::hasSPIDER(const Deck& deck) { + return deck.hasKeyword(); + } + + bool EclipseGrid::hasCylindricalKeywords(const Deck& deck) { if (deck.hasKeyword() && deck.hasKeyword() &&