Upgraded opm-flowdiagnostics-applications to d76ec747cf22aa4d235f6a6c83c3a814adcf5cb2

This commit is contained in:
sigurdp 2017-12-13 10:05:33 +01:00
parent 898c7a0483
commit 64fe9e9a3b
5 changed files with 154 additions and 17 deletions

View File

@ -14,7 +14,7 @@ set(ERT_GITHUB_SHA "2e36798b43daf18c112b91aa3febbf2fccd4a95f")
set(OPM_FLOWDIAGNOSTICS_SHA "7e2be931d430796ed42efcfb5c6b67a8d5962f7f")
# https://github.com/OPM/opm-flowdiagnostics-applications
set(OPM_FLOWDIAGNOSTICS_APPLICATIONS_SHA "a773bcfc963705679ecc28f58048fc38936fbbc6")
set(OPM_FLOWDIAGNOSTICS_APPLICATIONS_SHA "d76ec747cf22aa4d235f6a6c83c3a814adcf5cb2")
# https://github.com/OPM/opm-parser/blob/master/opm/parser/eclipse/Units/Units.hpp
# This file was moved from opm-core to opm-parser october 2016

View File

@ -28,10 +28,13 @@
#include <opm/utility/ECLResultData.hpp>
#include <opm/utility/ECLSaturationFunc.hpp>
#include <array>
#include <cstddef>
#include <exception>
#include <initializer_list>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <boost/filesystem.hpp>
@ -335,19 +338,90 @@ namespace {
return Opm::ECLUnits::serialisedUnitConventions(init);
}
Opm::SatFunc::EPSEvalInterface::InvalidEndpointBehaviour
handleInvalid(const std::string& behaviour)
{
using IEB = Opm::SatFunc::
EPSEvalInterface::InvalidEndpointBehaviour;
if ((behaviour == "ignore") ||
(behaviour == "ignore-point") ||
(behaviour == "ignore_point") ||
(behaviour == "ignorepoint"))
{
return IEB::IgnorePoint;
}
return IEB::UseUnscaled;
}
auto handleInvalid(const Opm::ParameterGroup& prm)
-> decltype(handleInvalid("ignore"))
{
for (const auto* param : { "handle_invalid" ,
"hInv", "handleInv" })
{
if (prm.has(param)) {
return handleInvalid(prm.get<std::string>(param));
}
}
return handleInvalid("ignore");
}
int getActiveCell(const Opm::ECLGraph& G,
const Opm::ParameterGroup& prm)
{
if (prm.has("cell")) { return prm.get<int>("cell"); }
const auto grid = prm.getDefault("gridName", std::string(""));
auto ijk = std::array<int,3>{ { 0, 0, 0 } };
if (prm.has("I")) { ijk[0] = prm.get<int>("I") - 1; } // 1-based
else if (prm.has("i")) { ijk[0] = prm.get<int>("i") - 0; } // 0-based
if (prm.has("J")) { ijk[1] = prm.get<int>("J") - 1; } // 1-based
else if (prm.has("j")) { ijk[1] = prm.get<int>("j") - 0; } // 0-based
if (prm.has("K")) { ijk[2] = prm.get<int>("K") - 1; } // 1-based
else if (prm.has("k")) { ijk[2] = prm.get<int>("k") - 0; } // 0-based
const auto acell = G.activeCell(ijk, grid);
if (acell < 0) {
std::cerr << "Cell ("
<< (ijk[0] + 1) << ", "
<< (ijk[1] + 1) << ", "
<< (ijk[2] + 1) << ") "
<< "in "
<< (grid.empty()
? std::string{"Main Grid"}
: "Local Grid: " + grid)
<< " is inactive.\n"
<< "Using Cell 0 in Main Grid\n";
return 0;
}
return acell;
}
} // namespace Anonymous
int main(int argc, char* argv[])
try {
const auto prm = example::initParam(argc, argv);
const auto useEPS = prm.getDefault("useEPS", false);
const auto cellID = prm.getDefault("cell", 0);
const auto h_inv = handleInvalid(prm);
const auto rset = example::identifyResultSet(prm);
const auto init = Opm::ECLInitFileData(rset.initFile());
const auto graph = Opm::ECLGraph::load(rset.gridFile(), init);
auto sfunc = Opm::ECLSaturationFunc(graph, init, useEPS);
const auto cellID = getActiveCell(graph, prm);
auto sfunc = Opm::ECLSaturationFunc(graph, init, useEPS, h_inv);
auto pvtCC = Opm::ECLPVT::ECLPvtCurveCollection(graph, init);
if (prm.has("unit")) {

View File

@ -28,6 +28,7 @@
#include <opm/utility/ECLResultData.hpp>
#include <cassert>
#include <cmath>
#include <exception>
#include <initializer_list>
#include <iterator>
@ -197,6 +198,12 @@ Impl::reverse(const TableEndPoints& tep,
const auto sLO = this->smin_[cell];
const auto sHI = this->smax_[cell];
if (! validSaturations({ sLO, sHI })) {
this->handleInvalidEndpoint(eval_pt, unscaledsat);
continue;
}
unscaledsat.push_back(0.0);
auto& s_unsc = unscaledsat.back();
@ -235,8 +242,12 @@ handleInvalidEndpoint(const SaturationAssoc& sp,
return;
}
// Nothing to do for IgnorePoint. In particular, we must not change the
// contents or the size of effsat.
if (this->handle_invalid_ == InvalidEndpointBehaviour::IgnorePoint) {
// User requests that invalid scaling be ignored. Signal invalid
// scaled saturation to caller as NaN.
effsat.push_back(std::nan(""));
return;
}
}
// ---------------------------------------------------------------------
@ -344,13 +355,19 @@ Impl::reverse(const TableEndPoints& tep,
for (const auto& eval_pt : sp) {
const auto cell = eval_pt.cell;
unscaledsat.push_back(0.0);
auto& s_unsc = unscaledsat.back();
const auto sLO = this->smin_ [cell];
const auto sR = this->sdisp_[cell];
const auto sHI = this->smax_ [cell];
if (! validSaturations({ sLO, sR, sHI })) {
this->handleInvalidEndpoint(eval_pt, unscaledsat);
continue;
}
unscaledsat.push_back(0.0);
auto& s_unsc = unscaledsat.back();
if (! (eval_pt.sat > tep.low)) {
// s <= minimum tabulated saturation.
// Map to Minimum Input Saturation in cell (sLO).
@ -396,8 +413,12 @@ handleInvalidEndpoint(const SaturationAssoc& sp,
return;
}
// Nothing to do for IgnorePoint. In particular, we must not change the
// contents or the size of effsat.
if (this->handle_invalid_ == InvalidEndpointBehaviour::IgnorePoint) {
// User requests that invalid scaling be ignored. Signal invalid
// scaled saturation to caller as NaN.
effsat.push_back(std::nan(""));
return;
}
}
// ---------------------------------------------------------------------

View File

@ -35,6 +35,7 @@
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <functional>
#include <memory>
@ -1620,6 +1621,11 @@ kroCurve(const ECLRegionMapping& rmap,
auto abscissas =
(subsys == RawCurve::SubSystem::OilGas) ? so_g : so_w;
if (abscissas.empty()) {
// No finite scaled saturations. Return empty.
return {};
}
const auto nPoints = abscissas.size();
// Re-expand input arrays to match size requirements of EPS evaluator.
@ -1703,6 +1709,12 @@ krgCurve(const ECLRegionMapping& rmap,
}
auto abscissas = sg_inp;
if (abscissas.empty()) {
// No finite scaled saturations. Return empty.
return {};
}
const auto nPoints = abscissas.size();
// Re-expand input arrays to match size requirements of EPS evaluator.
@ -1739,6 +1751,12 @@ pcgoCurve(const ECLRegionMapping& rmap,
}
auto abscissas = sg_inp;
if (abscissas.empty()) {
// No finite scaled saturations. Return empty.
return {};
}
const auto nPoints = abscissas.size();
// Re-expand input arrays to match size requirements of EPS evaluator.
@ -1823,6 +1841,12 @@ krwCurve(const ECLRegionMapping& rmap,
}
auto abscissas = sw_inp;
if (abscissas.empty()) {
// No finite scaled saturations. Return empty.
return {};
}
const auto nPoints = abscissas.size();
// Re-expand input arrays to match size requirements of EPS evaluator.
@ -1859,6 +1883,12 @@ pcowCurve(const ECLRegionMapping& rmap,
}
auto abscissas = sw_inp;
if (abscissas.empty()) {
// No finite scaled saturations. Return empty.
return {};
}
const auto nPoints = abscissas.size();
// Re-expand input arrays to match size requirements of EPS evaluator.
@ -1947,8 +1977,20 @@ void
Opm::ECLSaturationFunc::Impl::
uniqueReverseScaleSat(std::vector<double>& s) const
{
std::sort(std::begin(s), std::end(s));
auto u = std::unique(std::begin(s), std::end(s));
auto nan = std::partition(std::begin(s), std::end(s),
[](const double si)
{
return std::isfinite(si);
});
if (nan == std::begin(s)) {
// No finite scaled saturations. Return empty.
s.clear();
return;
}
std::sort(std::begin(s), nan);
auto u = std::unique(std::begin(s), nan);
s.assign(std::begin(s), u);
}

View File

@ -102,12 +102,12 @@ namespace Opm {
/// Default value (\c true) means that effects of EPS are
/// included if requisite data is present in the INIT result.
///
/// \param[in] invalidIsUnscaled Whether or not treat invalid scaled
/// saturation end-points (e.g., SWL=-1.0E+20) as unscaled
/// saturations. True for "treat as unscaled", false for "
/// \param[in] handle_invalid Run-time policy for how to handle
/// scaling requests relative to invalid scaled saturations
/// (e.g., SWL = -1.0E+20).
///
/// Default value (\c true) means that invalid scalings are
/// treated as unscaled, false
/// Default value (\c UseUnscaled) means that invalid scalings
/// are treated as unscaled.
ECLSaturationFunc(const ECLGraph& G,
const ECLInitFileData& init,
const bool useEPS = true,