diff --git a/opm/core/utility/thresholdPressures.hpp b/opm/core/utility/thresholdPressures.hpp
index 87e62ea2..8fda8cdc 100644
--- a/opm/core/utility/thresholdPressures.hpp
+++ b/opm/core/utility/thresholdPressures.hpp
@@ -17,13 +17,15 @@
along with OPM. If not, see .
*/
-#include
-#include
-#include
-
#ifndef OPM_THRESHOLDPRESSURES_HEADER_INCLUDED
#define OPM_THRESHOLDPRESSURES_HEADER_INCLUDED
+#include
+#include
+#include
+#include
+
+
namespace Opm
{
@@ -49,14 +51,11 @@ namespace Opm
std::vector thresholdPressures(const ParseMode& parseMode ,EclipseStateConstPtr eclipseState, const Grid& grid)
{
SimulationConfigConstPtr simulationConfig = eclipseState->getSimulationConfig();
- const std::vector>& thresholdPressureTable = simulationConfig->getThresholdPressureTable();
std::vector thpres_vals;
-
- if (thresholdPressureTable.size() > 0) {
-
+ if (simulationConfig->hasThresholdPressure()) {
+ std::shared_ptr thresholdPressure = simulationConfig->getThresholdPressure();
std::shared_ptr> eqlnum = eclipseState->getIntGridProperty("EQLNUM");
auto eqlnumData = eqlnum->getData();
- int maxEqlnum = *std::max_element(eqlnumData.begin(), eqlnumData.end());
// Set values for each face.
const int num_faces = UgGridHelpers::numFaces(grid);
@@ -70,14 +69,18 @@ namespace Opm
// Boundary face, skip this.
continue;
}
- const int eq1 = eqlnumData[gc[c1]] - 1;
- const int eq2 = eqlnumData[gc[c2]] - 1;
- std::pair value = thresholdPressureTable[eq1 + maxEqlnum*eq2];
- if(value.first){
- thpres_vals[face] = value.second;
- }else{
- std::string msg = "Inferring threshold pressure from the initial state is not supported.";
- parseMode.handleError( ParseMode::UNSUPPORTED_INITIAL_THPRES , msg );
+ const int gc1 = (gc == 0) ? c1 : gc[c1];
+ const int gc2 = (gc == 0) ? c2 : gc[c2];
+ const int eq1 = eqlnumData[gc1];
+ const int eq2 = eqlnumData[gc2];
+
+ if (thresholdPressure->hasRegionBarrier(eq1,eq2)) {
+ if (thresholdPressure->hasThresholdPressure(eq1,eq2)) {
+ thpres_vals[face] = thresholdPressure->getThresholdPressure(eq1,eq2);
+ } else {
+ std::string msg = "Initializing the THPRES pressure values from the initial state is not supported - using 0.0";
+ parseMode.handleError( ParseMode::UNSUPPORTED_INITIAL_THPRES , msg );
+ }
}
}
}