Merge pull request #860 from joakim-hove/THPRES

Using map base ThresholdPressure implementation.
This commit is contained in:
Joakim Hove 2015-08-25 16:23:56 +02:00
commit 6579a150f3
3 changed files with 78 additions and 18 deletions

View File

@ -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

View File

@ -17,13 +17,15 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <vector>
#include <opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
#include <opm/parser/eclipse/Parser/ParseMode.hpp>
#ifndef OPM_THRESHOLDPRESSURES_HEADER_INCLUDED
#define OPM_THRESHOLDPRESSURES_HEADER_INCLUDED
#include <vector>
#include <opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
#include <opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp>
#include <opm/parser/eclipse/Parser/ParseMode.hpp>
namespace Opm
{
@ -49,14 +51,11 @@ namespace Opm
std::vector<double> thresholdPressures(const ParseMode& parseMode ,EclipseStateConstPtr eclipseState, const Grid& grid)
{
SimulationConfigConstPtr simulationConfig = eclipseState->getSimulationConfig();
const std::vector<std::pair<bool, double>>& thresholdPressureTable = simulationConfig->getThresholdPressureTable();
std::vector<double> thpres_vals;
if (thresholdPressureTable.size() > 0) {
if (simulationConfig->hasThresholdPressure()) {
std::shared_ptr<const ThresholdPressure> thresholdPressure = simulationConfig->getThresholdPressure();
std::shared_ptr<GridProperty<int>> 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<bool, double> 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 );
}
}
}
}

View File

@ -0,0 +1,56 @@
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseMode.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/core/grid.h>
#include <opm/core/grid/cornerpoint_grid.h>
#include <opm/core/grid/GridManager.hpp>
#include <opm/autodiff/GridHelpers.hpp>
#include <opm/core/utility/thresholdPressures.hpp> // 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<double> porv = eclipseState->getDoubleGridProperty("PORV")->getData();
GridManager gridManager( eclipseState->getEclipseGrid(), porv );
const Grid& grid = *(gridManager.c_grid());
std::vector<double> threshold_pressures = thresholdPressures(parseMode, eclipseState, grid);
BOOST_CHECK( threshold_pressures.size() > 0 );
}