diff --git a/opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp b/opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp index b030a2569..dfd214e71 100644 --- a/opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp +++ b/opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp @@ -92,8 +92,6 @@ namespace Opm { void loadGridPropertyFromDeckKeyword(const Box& inputBox, const DeckKeyword& deckKeyword); - void setKeywordBox(const DeckKeyword& deckKeyword, const DeckRecord&, BoxManager& boxManager); - std::string m_defaultRegion; UnitSystem m_deckUnitSystem; GridProperties m_intGridProperties; diff --git a/src/opm/parser/eclipse/CMakeLists.txt b/src/opm/parser/eclipse/CMakeLists.txt index 8a85edf9d..f51756eb3 100644 --- a/src/opm/parser/eclipse/CMakeLists.txt +++ b/src/opm/parser/eclipse/CMakeLists.txt @@ -67,6 +67,7 @@ set(opmparser_SOURCES Deck/Deck.cpp EclipseState/Grid/NNC.cpp EclipseState/Grid/PinchMode.cpp EclipseState/Grid/SatfuncPropertyInitializers.cpp + EclipseState/Grid/setKeywordBox.cpp EclipseState/Grid/TransMult.cpp EclipseState/InitConfig/Equil.cpp EclipseState/InitConfig/InitConfig.cpp diff --git a/src/opm/parser/eclipse/EclipseState/Eclipse3DProperties.cpp b/src/opm/parser/eclipse/EclipseState/Eclipse3DProperties.cpp index f2bf09e0c..799c036fd 100644 --- a/src/opm/parser/eclipse/EclipseState/Eclipse3DProperties.cpp +++ b/src/opm/parser/eclipse/EclipseState/Eclipse3DProperties.cpp @@ -33,6 +33,8 @@ #include #include +#include "Grid/setKeywordBox.hpp" + namespace Opm { namespace { @@ -931,48 +933,4 @@ namespace Opm { return messages; } - - void Eclipse3DProperties::setKeywordBox( const DeckKeyword& deckKeyword, - const DeckRecord& deckRecord, - BoxManager& boxManager) { - const auto& I1Item = deckRecord.getItem("I1"); - const auto& I2Item = deckRecord.getItem("I2"); - const auto& J1Item = deckRecord.getItem("J1"); - const auto& J2Item = deckRecord.getItem("J2"); - const auto& K1Item = deckRecord.getItem("K1"); - const auto& K2Item = deckRecord.getItem("K2"); - - size_t setCount = 0; - - if (!I1Item.defaultApplied(0)) - setCount++; - - if (!I2Item.defaultApplied(0)) - setCount++; - - if (!J1Item.defaultApplied(0)) - setCount++; - - if (!J2Item.defaultApplied(0)) - setCount++; - - if (!K1Item.defaultApplied(0)) - setCount++; - - if (!K2Item.defaultApplied(0)) - setCount++; - - if (setCount == 6) { - boxManager.setKeywordBox( I1Item.get< int >(0) - 1, - I2Item.get< int >(0) - 1, - J1Item.get< int >(0) - 1, - J2Item.get< int >(0) - 1, - K1Item.get< int >(0) - 1, - K2Item.get< int >(0) - 1); - } else if (setCount != 0) { - std::string msg = "BOX modifiers on keywords must be either " - "specified completely or not at all. Ignoring."; - m_intGridProperties.getMessageContainer().error(deckKeyword.getFileName() + std::to_string(deckKeyword.getLineNumber()) + msg); - } - } } diff --git a/src/opm/parser/eclipse/EclipseState/Grid/GridProperties.cpp b/src/opm/parser/eclipse/EclipseState/Grid/GridProperties.cpp index 82ac11690..c899718db 100644 --- a/src/opm/parser/eclipse/EclipseState/Grid/GridProperties.cpp +++ b/src/opm/parser/eclipse/EclipseState/Grid/GridProperties.cpp @@ -112,49 +112,6 @@ namespace Opm { - void setKeywordBox( const DeckRecord& deckRecord, - BoxManager& boxManager) { - const auto& I1Item = deckRecord.getItem("I1"); - const auto& I2Item = deckRecord.getItem("I2"); - const auto& J1Item = deckRecord.getItem("J1"); - const auto& J2Item = deckRecord.getItem("J2"); - const auto& K1Item = deckRecord.getItem("K1"); - const auto& K2Item = deckRecord.getItem("K2"); - - size_t setCount = 0; - - if (!I1Item.defaultApplied(0)) - setCount++; - - if (!I2Item.defaultApplied(0)) - setCount++; - - if (!J1Item.defaultApplied(0)) - setCount++; - - if (!J2Item.defaultApplied(0)) - setCount++; - - if (!K1Item.defaultApplied(0)) - setCount++; - - if (!K2Item.defaultApplied(0)) - setCount++; - - if (setCount == 6) { - boxManager.setKeywordBox( I1Item.get< int >(0) - 1, - I2Item.get< int >(0) - 1, - J1Item.get< int >(0) - 1, - J2Item.get< int >(0) - 1, - K1Item.get< int >(0) - 1, - K2Item.get< int >(0) - 1); - } else if (setCount != 0) { - std::string msg = "BOX modifiers on keywords must be either " - "specified completely or not at all. Ignoring."; - throw std::invalid_argument( msg ); - } - } - template< typename T > const MessageContainer& GridProperties::getMessageContainer() const { return m_messages; diff --git a/src/opm/parser/eclipse/EclipseState/Grid/setKeywordBox.cpp b/src/opm/parser/eclipse/EclipseState/Grid/setKeywordBox.cpp new file mode 100644 index 000000000..2fa284c02 --- /dev/null +++ b/src/opm/parser/eclipse/EclipseState/Grid/setKeywordBox.cpp @@ -0,0 +1,43 @@ +/* + Copyright 2016 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . + */ + +#include "setKeywordBox.hpp" +namespace Opm { + + void setKeywordBox( const DeckRecord& deckRecord, + BoxManager& boxManager) { + const auto& I1Item = deckRecord.getItem("I1"); + const auto& I2Item = deckRecord.getItem("I2"); + const auto& J1Item = deckRecord.getItem("J1"); + const auto& J2Item = deckRecord.getItem("J2"); + const auto& K1Item = deckRecord.getItem("K1"); + const auto& K2Item = deckRecord.getItem("K2"); + + const auto& active_box = boxManager.getActiveBox(); + + const int i1 = I1Item.hasValue(0) ? I1Item.get(0) - 1 : active_box.I1(); + const int i2 = I2Item.hasValue(0) ? I2Item.get(0) - 1 : active_box.I2(); + const int j1 = J1Item.hasValue(0) ? J1Item.get(0) - 1 : active_box.J1(); + const int j2 = J2Item.hasValue(0) ? J2Item.get(0) - 1 : active_box.J2(); + const int k1 = K1Item.hasValue(0) ? K1Item.get(0) - 1 : active_box.K1(); + const int k2 = K2Item.hasValue(0) ? K2Item.get(0) - 1 : active_box.K2(); + + boxManager.setKeywordBox( i1,i2,j1,j2,k1,k2 ); + } +} diff --git a/src/opm/parser/eclipse/EclipseState/Grid/setKeywordBox.hpp b/src/opm/parser/eclipse/EclipseState/Grid/setKeywordBox.hpp new file mode 100644 index 000000000..76864bec7 --- /dev/null +++ b/src/opm/parser/eclipse/EclipseState/Grid/setKeywordBox.hpp @@ -0,0 +1,31 @@ +/* + Copyright 2016 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#ifndef SET_KEYWORDBOX_HPP +#define SET_KEYWORDBOX_HPP + +#include +#include + +namespace Opm { + +void setKeywordBox( const DeckRecord& deckRecord,BoxManager& boxManager); + +} +#endif diff --git a/tests/parser/Eclipse3DPropertiesTests.cpp b/tests/parser/Eclipse3DPropertiesTests.cpp index 240b15ed6..b93bba549 100644 --- a/tests/parser/Eclipse3DPropertiesTests.cpp +++ b/tests/parser/Eclipse3DPropertiesTests.cpp @@ -476,3 +476,86 @@ BOOST_AUTO_TEST_CASE(TEMPI_TEST) { Setup s(createDeck()); BOOST_CHECK_NO_THROW( s.props.getDoubleGridProperty("TEMPI") ); } + + +static Opm::Deck createMultiplyDeck() { + const auto* input = R"( +RUNSPEC + +TITLE + 'TITTEL' + +DIMENS + 100 21 20 / + +METRIC + +OIL +WATER + +TABDIMS +/ + +START + 19 JUN 2017 +/ + +WELLDIMS + 3 20 1 +/ + +EQLDIMS + 2* 100 2* / + +GRID + + +DXV + 5.0D0 10.0D0 2*20.0D0 45.0D0 95*50.0D0 +/ + +DYV + 21*4.285714D0 +/ + +DZV + 20*0.5D0 +/ + +TOPS + 2100*1000.0D0 +/ + + +PERMX + 42000*100.0D0 +/ + + +COPY + 'PERMX' 'PERMZ' / + 'PERMX' 'PERMY' / +/ + +MULTIPLY + 'PERMZ' 0.1D0 / + 'PERMX' 0.1D0 * * 1 21 * 1 / -- This is a weird way to specify the top layer! +/ +)"; + + Opm::Parser parser; + return parser.parseString(input, Opm::ParseContext() ); +} + + + + +BOOST_AUTO_TEST_CASE(DefaultedBox) { + const Setup s(createMultiplyDeck()); + + const auto& permx = s.props.getDoubleGridProperty("PERMX"); + const auto& permz = s.props.getDoubleGridProperty("PERMZ"); + + BOOST_CHECK_EQUAL( permx.iget(0,0,0) , permz.iget(0,0,0)); + BOOST_CHECK_EQUAL( permx.iget(0,0,1) * 0.10 , permz.iget(0,0,1)); +}