Make constructor generic.

This supports std::vector and Opm::TableColumn (from opm-parser) as before,
but without requiring any OPM includes, making the class independent.
This commit is contained in:
Atgeirr Flø Rasmussen 2018-01-11 15:00:49 +01:00
parent d700402b15
commit 2977d8659e

View File

@ -27,7 +27,6 @@
#include <utility> #include <utility>
#include <opm/common/ErrorMacros.hpp> #include <opm/common/ErrorMacros.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp>
#include <opm/core/utility/linearInterpolation.hpp> #include <opm/core/utility/linearInterpolation.hpp>
@ -50,14 +49,9 @@ namespace Opm
/// @brief Construct from vectors of x and y values. /// @brief Construct from vectors of x and y values.
/// @param x_values vector of domain values /// @param x_values vector of domain values
/// @param y_values vector of corresponding range values. /// @param y_values vector of corresponding range values.
NonuniformTableLinear(const std::vector<double>& x_values, template<class XContainer, class YContainer>
const std::vector<T>& y_values); NonuniformTableLinear(const XContainer& x_values,
const YContainer& y_values);
NonuniformTableLinear(const TableColumn& x_column,
const std::vector<T>& y_values);
NonuniformTableLinear(const TableColumn& x_column,
const TableColumn& y_column);
/// @brief Get the domain. /// @brief Get the domain.
/// @return the domain as a pair of doubles. /// @return the domain as a pair of doubles.
@ -130,10 +124,11 @@ namespace Opm
template<typename T> template<typename T>
template<class XContainer, class YContainer>
inline inline
NonuniformTableLinear<T> NonuniformTableLinear<T>
::NonuniformTableLinear(const TableColumn& x_column, ::NonuniformTableLinear(const XContainer& x_column,
const TableColumn& y_column) const YContainer& y_column)
: x_values_( x_column.begin() , x_column.end()), : x_values_( x_column.begin() , x_column.end()),
y_values_( y_column.begin() , y_column.end()) y_values_( y_column.begin() , y_column.end())
{ {
@ -141,29 +136,6 @@ namespace Opm
} }
template<typename T>
inline
NonuniformTableLinear<T>
::NonuniformTableLinear(const TableColumn& x_column,
const std::vector<T>& y_values)
: x_values_( x_column.begin() , x_column.end()),
y_values_(y_values)
{
assert(isNondecreasing(x_values_.begin(), x_values_.end()));
}
template<typename T>
inline
NonuniformTableLinear<T>
::NonuniformTableLinear(const std::vector<double>& x_values,
const std::vector<T>& y_values)
: x_values_(x_values), y_values_(y_values)
{
assert(isNondecreasing(x_values.begin(), x_values.end()));
}
template<typename T> template<typename T>
inline std::pair<double, double> inline std::pair<double, double>
NonuniformTableLinear<T> NonuniformTableLinear<T>