From 5f7a7d808378bd02f3aa8d59373cd93b520d85a5 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Mon, 10 Nov 2014 00:34:22 +0100 Subject: [PATCH] Removed EclipseState::hasGrid() method --- .../eclipse/EclipseState/EclipseState.cpp | 62 +------------------ .../eclipse/EclipseState/EclipseState.hpp | 1 - .../EclipseState/tests/EclipseStateTests.cpp | 33 ---------- 3 files changed, 1 insertion(+), 95 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/EclipseState.cpp b/opm/parser/eclipse/EclipseState/EclipseState.cpp index 3362b6009..2fc856b2b 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.cpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.cpp @@ -131,14 +131,8 @@ namespace Opm { return m_deckUnitSystem; } - bool EclipseState::hasEclipseGrid() const { - return static_cast(m_eclipseGrid); - } EclipseGridConstPtr EclipseState::getEclipseGrid() const { - if (!hasEclipseGrid()) - throw std::logic_error("The eclipse grid object cannot be retrieved if no grid is featured by the deck."); - return m_eclipseGrid; } @@ -259,12 +253,6 @@ namespace Opm { } void EclipseState::initTransMult(ParserLogPtr /*parserLog*/) { - if (!hasEclipseGrid()) - // no checking required here as the class will already - // refrain from processing the MULT* grid properties if no - // grid is available... - return; - EclipseGridConstPtr grid = getEclipseGrid(); m_transMult = std::make_shared( grid->getNX() , grid->getNY() , grid->getNZ()); @@ -285,16 +273,6 @@ namespace Opm { } void EclipseState::initFaults(DeckConstPtr deck, ParserLogPtr parserLog) { - if (!hasEclipseGrid()) { - if (deck->hasKeyword("FAULTS") || - deck->hasKeyword("MULTFAULT")) - { - throw std::logic_error("Grid could not be initialized, but fault transmissibility multipliers have been detected."); - } - else - return; - } - EclipseGridConstPtr grid = getEclipseGrid(); m_faults = std::make_shared(); std::shared_ptr gridSection(new Opm::GRIDSection(deck) ); @@ -356,14 +334,6 @@ namespace Opm { void EclipseState::initMULTREGT(DeckConstPtr deck, ParserLogPtr /*parserLog*/) { - if (!hasEclipseGrid()) { - if (deck->hasKeyword("MULTREGT")) { - throw std::logic_error("Grid could not be initialized, but region transmissibility multipliers have been detected."); - } - else - return; - } - EclipseGridConstPtr grid = getEclipseGrid(); std::shared_ptr scanner = std::make_shared(); @@ -390,12 +360,7 @@ namespace Opm { void EclipseState::initEclipseGrid(DeckConstPtr deck, ParserLogPtr parserLog) { - try { - m_eclipseGrid = EclipseGridConstPtr( new EclipseGrid(deck, parserLog)); - } catch (const std::exception& e) { - std::string msg("Could not create a grid: "+std::string(e.what())); - parserLog->addWarning("", -1, msg); - } + m_eclipseGrid = EclipseGridConstPtr( new EclipseGrid(deck, parserLog)); } @@ -736,31 +701,6 @@ namespace Opm { m_intGridProperties = std::make_shared >(m_eclipseGrid , supportedIntKeywords); m_doubleGridProperties = std::make_shared >(m_eclipseGrid , supportedDoubleKeywords); - if (!hasEclipseGrid()) { - // make sure that no grid properties are specified by the deck - for (size_t kwIdx = 0; kwIdx < deck->size(); ++ kwIdx) { - const std::string& kwName = deck->getKeyword(kwIdx)->name(); - if (supportsGridProperty(kwName)) - throw std::logic_error("Grid could not be initialized, but grid property " + kwName + " has been detected."); - } - - // make sure that no grid property modifier keywords - // (which can make grid properties appear out of thin air) - // are present in the deck. - if (deck->hasKeyword("ADD") || - deck->hasKeyword("BOX") || - deck->hasKeyword("COPY") || - deck->hasKeyword("EQUALS") || - deck->hasKeyword("MULTIPLY")) - { - throw std::logic_error("Grid could not be initialized, but grid properties have been detected."); - } - - // if we don't have a grid and also no grid properties, we - // just skip this method. - return; - } - // actually create the grid property objects. we need to first // process all integer grid properties before the double ones // as these may be needed in order to initialize the double diff --git a/opm/parser/eclipse/EclipseState/EclipseState.hpp b/opm/parser/eclipse/EclipseState/EclipseState.hpp index ca8f8c320..a6586ae4c 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.hpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.hpp @@ -67,7 +67,6 @@ namespace Opm { EclipseState(DeckConstPtr deck, ParserLogPtr parserLog = std::make_shared(&std::cout)); ScheduleConstPtr getSchedule() const; - bool hasEclipseGrid() const; EclipseGridConstPtr getEclipseGrid() const; EclipseGridPtr getEclipseGridCopy() const; bool hasPhase(enum Phase::PhaseEnum phase) const; diff --git a/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp b/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp index 509cd179f..5b578621c 100644 --- a/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp +++ b/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp @@ -112,24 +112,7 @@ BOOST_AUTO_TEST_CASE(GetPOROTOPBased) { } -static DeckPtr createEmptyDeck() { - const char *deckData = - ""; - ParserPtr parser(new Parser()); - return parser->parseString(deckData) ; -} - -static DeckPtr createDeckWithoutGrid() { - const char *deckData = - "PROPS\n" - "EQUALS\n" - "'PERMX' 1.23 /\n" - "/\n"; - - ParserPtr parser(new Parser()); - return parser->parseString(deckData) ; -} static DeckPtr createDeck() { const char *deckData = @@ -227,22 +210,6 @@ BOOST_AUTO_TEST_CASE(TitleCorrect) { BOOST_CHECK_EQUAL( state.getTitle(), "The title"); } -BOOST_AUTO_TEST_CASE(SupportsEmptyDeck) { - DeckPtr deck = createEmptyDeck(); - ParserLogPtr parserLog(new ParserLog); - BOOST_CHECK_NO_THROW(EclipseState(deck, parserLog)); - - // we need to get a warning because no grid could be instantiated - BOOST_CHECK_EQUAL(parserLog->numWarnings(), 1); -} - -BOOST_AUTO_TEST_CASE(SupportsDeckWithoutGrid) { - DeckPtr deck = createDeckWithoutGrid(); - ParserLogPtr parserLog(new ParserLog); - - // specifying grid properties without a grid is not supported! - BOOST_CHECK_THROW(EclipseState(deck, parserLog), std::logic_error); -} BOOST_AUTO_TEST_CASE(IntProperties) { DeckPtr deck = createDeck();