From f71ba5a9f7fd014194ae6b1f8769a1bbe3575c29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 21 Jan 2014 17:49:02 +0100 Subject: [PATCH] Install crude handling of data point outside vertical span The initial implementation of RK4IVP<>::operator() failed to take into account the possibility that we might need to evaluate the function outside the vertical span for which it was initially defined. This situation occurs, for instance, in the not uncommon cases of the GOC being above or the WOC being below the model. This commit installs a crude Hermitian extrapolation procedure to handle these cases. Refinements are likely. --- opm/core/simulator/initStateEquil_impl.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/opm/core/simulator/initStateEquil_impl.hpp b/opm/core/simulator/initStateEquil_impl.hpp index befbf2757..ffc566be3 100644 --- a/opm/core/simulator/initStateEquil_impl.hpp +++ b/opm/core/simulator/initStateEquil_impl.hpp @@ -73,9 +73,13 @@ namespace Opm // Dense output (O(h**3)) according to Shampine // (Hermite interpolation) const double h = stepsize(); - const int i = (x - span_[0]) / h; + int i = (x - span_[0]) / h; const double t = (x - (span_[0] + i*h)) / h; + // Crude handling of evaluation point outside "span_"; + if (i < 0) { i = 0; } + if (N_ <= i) { i = N_ - 1; } + const double y0 = y_[i], y1 = y_[i + 1]; const double f0 = f_[i], f1 = f_[i + 1];