Add guard against invalid satnum, pvtnum, imbnum, eqlnum

This commit is contained in:
Tor Harald Sandve committed 2023-06-26 13:11:19 +02:00
1 parent a363ad6028
commit 40bd07a3b5
4 files changed
+37 -13

No files matched your search

+10
View File
@@ -44,6 +44,7 @@
#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <dune/grid/common/mcmgmapper.hh>
#include <fmt/format.h>
@@ -1278,6 +1279,15 @@ equilnum(const EclipseState& eclipseState,
const auto& e = eclipseState.fieldProps().get_int("EQLNUM");
std::transform(e.begin(), e.end(), eqlnum.begin(), [](int n){ return n - 1;});
}
OPM_BEGIN_PARALLEL_TRY_CATCH();
const int num_regions = eclipseState.getTableManager().getEqldims().getNumEquilRegions();
if ( std::any_of(eqlnum.begin(), eqlnum.end(), [num_regions](int n){return n >= num_regions;}) ) {
throw std::runtime_error("Values larger than maximum Equil regions " + std::to_string(num_regions) + " provided in EQLNUM");
}
if ( std::any_of(eqlnum.begin(), eqlnum.end(), [](int n){return n < 0;}) ) {
throw std::runtime_error("zero or negative values provided in EQLNUM");
}
OPM_END_PARALLEL_TRY_CATCH("Invalied EQLNUM numbers: ", gridview.comm());
return eqlnum;
}