21#ifndef OPM_NONUNIFORMTABLELINEAR_HEADER_INCLUDED
22#define OPM_NONUNIFORMTABLELINEAR_HEADER_INCLUDED
29#include <opm/common/ErrorMacros.hpp>
30#include <opm/common/utility/numeric/linearInterpolation.hpp>
52 template<
class XContainer,
class YContainer>
54 const YContainer& y_values);
58 std::pair<double, double>
domain();
77 double inverse(
const double y)
const;
85 std::vector<double> x_values_;
86 std::vector<T> y_values_;
87 mutable std::vector<T> x_values_reversed_;
88 mutable std::vector<T> y_values_reversed_;
99 template <
typename FI>
102 if (beg == end)
return true;
106 for (; it != end; ++it, ++prev) {
120 NonuniformTableLinear<T>
121 ::NonuniformTableLinear()
127 template<
class XContainer,
class YContainer>
131 const YContainer& y_column)
132 : x_values_( x_column.begin() , x_column.end()),
133 y_values_( y_column.begin() , y_column.end())
140 inline std::pair<double, double>
144 return std::make_pair(x_values_[0], x_values_.back());
152 const double a = x_values_[0];
153 const double b = x_values_.back();
154 const double c = new_domain.first;
155 const double d = new_domain.second;
157 for (
int i = 0; i < int(x_values_.size()); ++i) {
158 x_values_[i] = (x_values_[i] - a)*(d - c)/(b - a) + c;
167 return Opm::linearInterpolation(x_values_, y_values_, x);
175 return Opm::linearInterpolationDerivative(x_values_, y_values_, x);
183 if (y_values_.front() < y_values_.back()) {
184 return Opm::linearInterpolation(y_values_, x_values_, y);
186 if (y_values_reversed_.empty()) {
187 y_values_reversed_ = y_values_;
188 std::reverse(y_values_reversed_.begin(), y_values_reversed_.end());
189 assert(
isNondecreasing(y_values_reversed_.begin(), y_values_reversed_.end()));
190 x_values_reversed_ = x_values_;
191 std::reverse(x_values_reversed_.begin(), x_values_reversed_.end());
193 return Opm::linearInterpolation(y_values_reversed_, x_values_reversed_, y);
202 return x_values_ == other.x_values_
203 && y_values_ == other.y_values_;
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
bool isNondecreasing(const FI beg, const FI end)
Detect if a sequence is nondecreasing.
Definition NonuniformTableLinear.hpp:100