#7335 Dual poro models : Throw exception if invalid data is detected

This commit is contained in:
Magne Sjaastad 2021-02-07 21:27:32 +01:00
parent b77da64b6d
commit 7aa3a47b36
5 changed files with 46 additions and 9 deletions

View File

@ -309,7 +309,12 @@ Opm::ECLPVT::surfaceMassDensity(const ECLInitFileData& init,
const auto& tab = init.keywordData<double>("TAB");
// Subtract one to account for 1-based indices.
const auto start = std::max(tabdims[ TABDIMS_IBDENS_OFFSET_ITEM ] - 1, 0);
const auto start = tabdims[ TABDIMS_IBDENS_OFFSET_ITEM ] - 1;
if (start < 0) {
throw std::invalid_argument(
"Invalid table offset for TABDIMS_IBDENS_OFFSET_ITEM");
}
const auto nreg = tabdims[ TABDIMS_NTDENS_ITEM ];
// Phase densities for 'phase' constitute 'nreg' consecutive entries

View File

@ -641,7 +641,11 @@ fromECLOutput(const ECLInitFileData& init)
const auto nTabElem = raw.numPrimary * raw.numTables;
// Subtract one to account for 1-based indices.
const auto start = std::max(tabdims[ TABDIMS_JBPVTG_OFFSET_ITEM ] - 1, 0);
const auto start = tabdims[ TABDIMS_JBPVTG_OFFSET_ITEM ] - 1;
if (start < 0) {
throw std::invalid_argument(
"Invalid table offset for TABDIMS_JBPVTG_OFFSET_ITEM");
}
raw.primaryKey.assign(&tab[start], &tab[start] + nTabElem);
}
@ -652,7 +656,11 @@ fromECLOutput(const ECLInitFileData& init)
raw.numPrimary * raw.numRows * raw.numCols * raw.numTables;
// Subtract one to account for 1-based indices.
const auto start = std::max(tabdims[ TABDIMS_IBPVTG_OFFSET_ITEM ] - 1, 0);
const auto start = tabdims[ TABDIMS_IBPVTG_OFFSET_ITEM ] - 1;
if (start < 0) {
throw std::invalid_argument(
"Invalid table offset for TABDIMS_IBPVTG_OFFSET_ITEM");
}
raw.data.assign(&tab[start], &tab[start] + nTabElem);
}

View File

@ -836,7 +836,11 @@ fromECLOutput(const ECLInitFileData& init)
const auto nTabElem = raw.numPrimary * raw.numTables;
// Subtract one to account for 1-based indices.
const auto start = std::max(tabdims[ TABDIMS_JBPVTO_OFFSET_ITEM ] - 1, 0);
const auto start = tabdims[ TABDIMS_JBPVTO_OFFSET_ITEM ] - 1;
if (start < 0) {
throw std::invalid_argument(
"Invalid table offset for TABDIMS_JBPVTO_OFFSET_ITEM");
}
raw.primaryKey.assign(&tab[start], &tab[start] + nTabElem);
}
@ -847,7 +851,11 @@ fromECLOutput(const ECLInitFileData& init)
raw.numPrimary * raw.numRows * raw.numCols * raw.numTables;
// Subtract one to account for 1-based indices.
const auto start = std::max(tabdims[ TABDIMS_IBPVTO_OFFSET_ITEM ] - 1, 0);
const auto start = tabdims[ TABDIMS_IBPVTO_OFFSET_ITEM ] - 1;
if (start < 0) {
throw std::invalid_argument(
"Invalid table offset for TABDIMS_IBPVTO_OFFSET_ITEM");
}
raw.data.assign(&tab[start], &tab[start] + nTabElem);
}

View File

@ -363,7 +363,11 @@ fromECLOutput(const ECLInitFileData& init)
raw.numPrimary * raw.numRows * raw.numCols * raw.numTables;
// Subtract one to account for 1-based indices.
const auto start = std::max(tabdims[ TABDIMS_IBPVTW_OFFSET_ITEM ] - 1, 0);
const auto start = tabdims[ TABDIMS_IBPVTW_OFFSET_ITEM ] - 1;
if (start < 0) {
throw std::invalid_argument(
"Invalid table offset for TABDIMS_IBPVTW_OFFSET_ITEM");
}
raw.data.assign(&tab[start], &tab[start] + nTabElem);
}

View File

@ -597,7 +597,11 @@ Gas::Details::tableData(const std::vector<int>& tabdims,
const auto nTabElems = t.numRows * t.numTables * t.numCols;
// Subtract one to account for offset being one-based index.
const auto start = std::max(tabdims[ TABDIMS_IBSGFN_OFFSET_ITEM ] - 1, 0);
const auto start = tabdims[ TABDIMS_IBSGFN_OFFSET_ITEM ] - 1;
if (start < 0) {
throw std::invalid_argument(
"Invalid table offset for TABDIMS_IBSGFN_OFFSET_ITEM");
}
t.data.assign(&tab[start], &tab[start] + nTabElems);
@ -648,7 +652,11 @@ Oil::Details::tableData(const std::vector<int>& tabdims,
const auto nTabElems = t.numRows * t.numTables * t.numCols;
// Subtract one to account for offset being one-based index.
const auto start = std::max(tabdims[ TABDIMS_IBSOFN_OFFSET_ITEM ] - 1, 0);
const auto start = tabdims[ TABDIMS_IBSOFN_OFFSET_ITEM ] - 1;
if (start < 0) {
throw std::invalid_argument(
"Invalid table offset for TABDIMS_IBSOFN_OFFSET_ITEM");
}
t.data.assign(&tab[start], &tab[start] + nTabElems);
@ -688,7 +696,11 @@ Water::Details::tableData(const std::vector<int>& tabdims,
const auto nTabElems = t.numRows * t.numTables * t.numCols;
// Subtract one to account for offset being one-based index.
const auto start = std::max(tabdims[ TABDIMS_IBSWFN_OFFSET_ITEM ] - 1, 0);
const auto start = tabdims[ TABDIMS_IBSWFN_OFFSET_ITEM ] - 1;
if (start < 0) {
throw std::invalid_argument(
"Invalid table offset for TABDIMS_IBSWFN_OFFSET_ITEM");
}
t.data.assign(&tab[start], &tab[start] + nTabElems);