diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index f37a71a9..725aa311 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -170,7 +170,8 @@ list (APPEND TEST_SOURCE_FILES tests/test_parallelistlinformation.cpp tests/test_sparsevector.cpp tests/test_sparsetable.cpp - tests/test_velocityinterpolation.cpp + #tests/test_thresholdpressure.cpp + tests/test_velocityinterpolation.cpp tests/test_quadratures.cpp tests/test_uniformtablelinear.cpp tests/test_wells.cpp 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 ); + } } } } diff --git a/tests/test_thresholdpressure.cpp b/tests/test_thresholdpressure.cpp new file mode 100644 index 00000000..61d2b41a --- /dev/null +++ b/tests/test_thresholdpressure.cpp @@ -0,0 +1,56 @@ +#include +#include +#include + +#include +#include +#include +#include +#include // Note: the GridHelpers must be included before this (to make overloads available) + + +static DeckPtr createDeckSimConfig() { + const std::string& inputStr = "RUNSPEC\n" + "EQLOPTS\n" + "THPRES /\n " + "DIMENS\n" + "10 3 4 /\n" + "\n" + "GRID\n" + "REGIONS\n" + "EQLNUM\n" + "10*1 10*2 100*3 /\n " + "\n" + + "SOLUTION\n" + "THPRES\n" + "1 2 12.0/\n" + "1 3 5.0/\n" + "2 3 7.0/\n" + "/\n" + "\n"; + + + ParserPtr parser(new Parser()); + return parser->parseString(inputStr, ParseMode()) ; +} + +/* + The main purpose of this is to get the code in + thresholdPressures.hpp to compile; it currently has no users in the + opm-core codebase. +*/ + +BOOST_AUTO_TEST_CASE(CreateSimulationConfig) { + ParseMode parseMode; + typedef UnstructuredGrid Grid; + DeckPtr deck = createDeckSimConfig(); + EclipseState state(deck, parseMode); + EclipseGridConstPtr eclipseGrid = state.getEclipseGrid(); + std::vector porv = eclipseState->getDoubleGridProperty("PORV")->getData(); + GridManager gridManager( eclipseState->getEclipseGrid(), porv ); + const Grid& grid = *(gridManager.c_grid()); + + std::vector threshold_pressures = thresholdPressures(parseMode, eclipseState, grid); + BOOST_CHECK( threshold_pressures.size() > 0 ); +}