EclipseState now handles COPY keyword.
This commit is contained in:
committed by
Andreas Lauser
parent
bd1c756e30
commit
6301fd1ad7
@@ -118,11 +118,11 @@ namespace Opm {
|
||||
|
||||
void EclipseState::initProperties(DeckConstPtr deck) {
|
||||
BoxManager boxManager(m_eclipseGrid->getNX( ) , m_eclipseGrid->getNY() , m_eclipseGrid->getNZ());
|
||||
std::vector<std::pair<std::string , int> > supportedIntKeywords = {{ "SATNUM" , 0 }}; // Should come in config ....
|
||||
std::vector<std::pair<std::string , int> > supportedIntKeywords = {{ "SATNUM" , 0 },
|
||||
{ "PVTNUM" , 0 },
|
||||
{ "FIPNUM" , 0 }};
|
||||
m_intGridProperties = std::make_shared<GridProperties<int> >(m_eclipseGrid->getNX() , m_eclipseGrid->getNY() , m_eclipseGrid->getNZ() , supportedIntKeywords);
|
||||
|
||||
|
||||
|
||||
if (Section::hasREGIONS(deck)) {
|
||||
std::shared_ptr<Opm::REGIONSSection> regionsSection(new Opm::REGIONSSection(deck) );
|
||||
|
||||
@@ -138,6 +138,9 @@ namespace Opm {
|
||||
if (deckKeyword->name() == "ENDBOX")
|
||||
handleENDBOXKeyword(deckKeyword , boxManager);
|
||||
|
||||
if (deckKeyword->name() == "COPY")
|
||||
handleCOPYKeyword(deckKeyword , boxManager);
|
||||
|
||||
std::cout << "Looking at kw: " << deckKeyword->name() << std::endl;
|
||||
}
|
||||
}
|
||||
@@ -161,4 +164,71 @@ namespace Opm {
|
||||
boxManager.endInputBox();
|
||||
}
|
||||
|
||||
|
||||
void EclipseState::handleCOPYKeyword(DeckKeywordConstPtr deckKeyword , BoxManager& boxManager) {
|
||||
for (auto iter = deckKeyword->begin(); iter != deckKeyword->end(); ++iter) {
|
||||
DeckRecordConstPtr record = *iter;
|
||||
const std::string& srcField = record->getItem("src")->getString(0);
|
||||
const std::string& targetField = record->getItem("target")->getString(0);
|
||||
|
||||
setKeywordBox( record , boxManager );
|
||||
|
||||
|
||||
if (m_intGridProperties->hasKeyword( srcField ))
|
||||
copyIntKeyword( srcField , targetField , boxManager.getActiveBox());
|
||||
else
|
||||
throw std::invalid_argument("Fatal error processing COPY keyword. Tried to copy from not defined keyword" + srcField);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EclipseState::copyIntKeyword(const std::string& srcField , const std::string& targetField , std::shared_ptr<const Box> inputBox) {
|
||||
std::shared_ptr<const GridProperty<int> > src = m_intGridProperties->getKeyword( srcField );
|
||||
std::shared_ptr<GridProperty<int> > target = m_intGridProperties->getKeyword( targetField );
|
||||
|
||||
target->copyFrom( *src , inputBox );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EclipseState::setKeywordBox(DeckRecordConstPtr deckRecord , BoxManager& boxManager) {
|
||||
DeckItemConstPtr I1Item = deckRecord->getItem("I1");
|
||||
DeckItemConstPtr I2Item = deckRecord->getItem("I2");
|
||||
DeckItemConstPtr J1Item = deckRecord->getItem("J1");
|
||||
DeckItemConstPtr J2Item = deckRecord->getItem("J2");
|
||||
DeckItemConstPtr K1Item = deckRecord->getItem("K1");
|
||||
DeckItemConstPtr K2Item = deckRecord->getItem("K2");
|
||||
|
||||
size_t defaultCount = 0;
|
||||
|
||||
if (I1Item->defaultApplied())
|
||||
defaultCount++;
|
||||
|
||||
if (I2Item->defaultApplied())
|
||||
defaultCount++;
|
||||
|
||||
if (J1Item->defaultApplied())
|
||||
defaultCount++;
|
||||
|
||||
if (J2Item->defaultApplied())
|
||||
defaultCount++;
|
||||
|
||||
if (K1Item->defaultApplied())
|
||||
defaultCount++;
|
||||
|
||||
if (K2Item->defaultApplied())
|
||||
defaultCount++;
|
||||
|
||||
if (defaultCount == 0) {
|
||||
boxManager.setKeywordBox( I1Item->getInt(0) - 1,
|
||||
I2Item->getInt(0) - 1,
|
||||
J1Item->getInt(0) - 1,
|
||||
J2Item->getInt(0) - 1,
|
||||
K1Item->getInt(0) - 1,
|
||||
K2Item->getInt(0) - 1);
|
||||
} else if (defaultCount != 6)
|
||||
throw std::invalid_argument("When using BOX modifiers on keywords you must specify the BOX completely.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,9 +52,11 @@ namespace Opm {
|
||||
void initTitle(DeckConstPtr deck);
|
||||
void initProperties(DeckConstPtr deck);
|
||||
|
||||
void setKeywordBox(DeckRecordConstPtr deckRecord , BoxManager& boxManager);
|
||||
void handleBOXKeyword(DeckKeywordConstPtr deckKeyword , BoxManager& boxManager);
|
||||
void handleENDBOXKeyword(DeckKeywordConstPtr deckKeyword , BoxManager& boxManager);
|
||||
|
||||
void handleCOPYKeyword(DeckKeywordConstPtr deckKeyword , BoxManager& boxManager);
|
||||
void copyIntKeyword(const std::string& srcField , const std::string& targetField , std::shared_ptr<const Box> inputBox);
|
||||
|
||||
EclipseGridConstPtr m_eclipseGrid;
|
||||
ScheduleConstPtr schedule;
|
||||
|
||||
@@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE(IntProperties) {
|
||||
DeckPtr deck = createDeck();
|
||||
EclipseState state(deck);
|
||||
|
||||
BOOST_CHECK_EQUAL( false , state.supportsGridProperty("PVTNUM"));
|
||||
BOOST_CHECK_EQUAL( false , state.supportsGridProperty("NONO"));
|
||||
BOOST_CHECK_EQUAL( true , state.supportsGridProperty("SATNUM"));
|
||||
BOOST_CHECK_EQUAL( true , state.hasIntGridProperty("SATNUM"));
|
||||
}
|
||||
|
||||
@@ -29,12 +29,18 @@
|
||||
using namespace Opm;
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( PARSE_BOX_OK ) {
|
||||
EclipseState makeState(const std::string& fileName) {
|
||||
ParserPtr parser(new Parser( ));
|
||||
boost::filesystem::path boxFile("testdata/integration_tests/BOX/BOXTEST1");
|
||||
boost::filesystem::path boxFile(fileName);
|
||||
DeckPtr deck = parser->parseFile(boxFile.string() , false);
|
||||
EclipseState state(deck);
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( PARSE_BOX_OK ) {
|
||||
EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1");
|
||||
std::shared_ptr<GridProperty<int> > satnum = state.getIntProperty("SATNUM");
|
||||
{
|
||||
size_t i,j,k;
|
||||
@@ -54,3 +60,15 @@ BOOST_AUTO_TEST_CASE( PARSE_BOX_OK ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( PARSE_COPY ) {
|
||||
EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1");
|
||||
BOOST_CHECK(state.hasIntGridProperty( "FIPNUM" ));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( INCOMPLETE_KEYWORD_BOX) {
|
||||
BOOST_CHECK_THROW( makeState("testdata/integration_tests/BOX/BOXTEST2") , std::invalid_argument);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user