Added BoxTest which will throw for oversized keyword

This commit is contained in:
Joakim Hove
2014-10-13 14:56:02 +02:00
parent c637463327
commit a50e66b8a9
3 changed files with 93 additions and 15 deletions

View File

@@ -226,29 +226,49 @@ public:
return m_data;
}
void loadFromDeckKeyword(std::shared_ptr<const Box> inputBox, DeckKeywordConstPtr deckKeyword) {
const auto deckItem = getDeckItem(deckKeyword);
const std::vector<size_t>& indexList = inputBox->getIndexList();
for (size_t sourceIdx = 0; sourceIdx < indexList.size(); sourceIdx++) {
size_t targetIdx = indexList[sourceIdx];
if (sourceIdx < deckItem->size()
&& !deckItem->defaultApplied(sourceIdx))
{
setDataPoint(sourceIdx, targetIdx, deckItem);
}
}
}
/**
Due to the convention where it is only neceassary to supply the
top layer of the petrophysical properties we can unfortunately
not enforce that the number of elements elements in the
deckkeyword equals nx*ny*nz.
*/
void loadFromDeckKeyword(DeckKeywordConstPtr deckKeyword) {
const auto deckItem = getDeckItem(deckKeyword);
for (size_t dataPointIdx = 0; dataPointIdx < deckItem->size(); ++dataPointIdx) {
if (!deckItem->defaultApplied(dataPointIdx))
setDataPoint(dataPointIdx, dataPointIdx, deckItem);
}
}
void loadFromDeckKeyword(std::shared_ptr<const Box> inputBox, DeckKeywordConstPtr deckKeyword) {
if (inputBox->isGlobal())
loadFromDeckKeyword( deckKeyword );
else {
const auto deckItem = getDeckItem(deckKeyword);
const std::vector<size_t>& indexList = inputBox->getIndexList();
if (indexList.size() == deckItem->size()) {
for (size_t sourceIdx = 0; sourceIdx < indexList.size(); sourceIdx++) {
size_t targetIdx = indexList[sourceIdx];
if (sourceIdx < deckItem->size()
&& !deckItem->defaultApplied(sourceIdx))
{
setDataPoint(sourceIdx, targetIdx, deckItem);
}
}
} else {
std::string boxSize = std::to_string(static_cast<long long>(indexList.size()));
std::string keywordSize = std::to_string(static_cast<long long>(deckItem->size()));
throw std::invalid_argument("Size mismatch: Box:" + boxSize + " DecKeyword:" + keywordSize);
}
}
}
void copyFrom(const GridProperty<T>& src, std::shared_ptr<const Box> inputBox) {
if (inputBox->isGlobal()) {
for (size_t i = 0; i < src.getCartesianSize(); ++i)

View File

@@ -126,10 +126,17 @@ BOOST_AUTO_TEST_CASE( PARSE_MULTIPLY_COPY ) {
BOOST_AUTO_TEST_CASE( INCOMPLETE_KEYWORD_BOX) {
ParserLogPtr parserLog(new ParserLog());
makeState("testdata/integration_tests/BOX/BOXTEST2", parserLog);
parserLog->printAll();
BOOST_CHECK(parserLog->numErrors() > 1);
}
BOOST_AUTO_TEST_CASE( KEYWORD_BOX_TOO_SMALL) {
ParserLogPtr parserLog(new ParserLog());
BOOST_CHECK_THROW( makeState("testdata/integration_tests/BOX/BOXTEST3", parserLog) , std::invalid_argument);
}
BOOST_AUTO_TEST_CASE( EQUAL ) {
ParserLogPtr parserLog(new ParserLog());
EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1", parserLog);

51
testdata/integration_tests/BOX/BOXTEST3 vendored Normal file
View File

@@ -0,0 +1,51 @@
RUNSPEC
DIMENS
10 10 10 /
GRID
DX
1000*0.25 /
DYV
10*0.25 /
DZ
1000*0.25 /
TOPS
1000*0.25 /
EDIT
OIL
GAS
TITLE
The title
START
8 MAR 1998 /
PROPS
REGIONS
SATNUM
1000*2 /
BOX
1 2 1 2 1 2 /
SATNUM
80*10 / -- Too many elements in BOX
ENDBOX
SOLUTION
SCHEDULE