mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
not extrapolating towards negative in VFP tables
This commit is contained in:
@@ -199,15 +199,19 @@ struct InterpData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to find indices etc. for linear interpolation and extrapolation
|
* Helper function to find indices etc. for linear interpolation and extrapolation
|
||||||
* @param value Value to find in values
|
* @param value_in Value to find in values
|
||||||
* @param values Sorted list of values to search for value in.
|
* @param values Sorted list of values to search for value in.
|
||||||
* @return Data required to find the interpolated value
|
* @return Data required to find the interpolated value
|
||||||
*/
|
*/
|
||||||
inline InterpData findInterpData(const double& value, const std::vector<double>& values) {
|
inline InterpData findInterpData(const double& value_in, const std::vector<double>& values) {
|
||||||
InterpData retval;
|
InterpData retval;
|
||||||
|
|
||||||
const int nvalues = values.size();
|
const int nvalues = values.size();
|
||||||
|
|
||||||
|
// chopping the value to be zero, which means we do not
|
||||||
|
// extrapolate the table towards nagative ranges
|
||||||
|
const double value = value_in < 0.? 0. : value_in;
|
||||||
|
|
||||||
//If we only have one value in our vector, return that
|
//If we only have one value in our vector, return that
|
||||||
if (values.size() == 1) {
|
if (values.size() == 1) {
|
||||||
retval.ind_[0] = 0;
|
retval.ind_[0] = 0;
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(findInterpData)
|
|||||||
|
|
||||||
BOOST_CHECK_EQUAL(eval2.ind_[0], 0);
|
BOOST_CHECK_EQUAL(eval2.ind_[0], 0);
|
||||||
BOOST_CHECK_EQUAL(eval2.ind_[1], 1);
|
BOOST_CHECK_EQUAL(eval2.ind_[1], 1);
|
||||||
BOOST_CHECK_EQUAL(eval2.factor_, -0.5);
|
BOOST_CHECK_EQUAL(eval2.factor_, -0.25);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(eval3.ind_[0], 4);
|
BOOST_CHECK_EQUAL(eval3.ind_[0], 4);
|
||||||
BOOST_CHECK_EQUAL(eval3.ind_[1], 5);
|
BOOST_CHECK_EQUAL(eval3.ind_[1], 5);
|
||||||
|
|||||||
Reference in New Issue
Block a user