diff --git a/opm/core/props/IncompPropertiesFromDeck.cpp b/opm/core/props/IncompPropertiesFromDeck.cpp index 98e6a8e1a..b501582e1 100644 --- a/opm/core/props/IncompPropertiesFromDeck.cpp +++ b/opm/core/props/IncompPropertiesFromDeck.cpp @@ -32,7 +32,7 @@ namespace Opm { rock_.init(eclState, grid.number_of_cells, grid.global_cell, grid.cartdims); pvt_.init(deck); - satprops_.init(deck, eclState, grid, 200); + satprops_.init(deck, eclState, grid); if (pvt_.numPhases() != satprops_.numPhases()) { OPM_THROW(std::runtime_error, "IncompPropertiesFromDeck::IncompPropertiesFromDeck() - Inconsistent number of phases in pvt data (" << pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_.numPhases() << ")."); diff --git a/opm/core/props/IncompPropertiesFromDeck.hpp b/opm/core/props/IncompPropertiesFromDeck.hpp index 0ac4a71d2..e71ecb781 100644 --- a/opm/core/props/IncompPropertiesFromDeck.hpp +++ b/opm/core/props/IncompPropertiesFromDeck.hpp @@ -138,7 +138,7 @@ namespace Opm private: RockFromDeck rock_; PvtPropertiesIncompFromDeck pvt_; - SaturationPropsFromDeck satprops_; + SaturationPropsFromDeck satprops_; }; diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck.hpp b/opm/core/props/satfunc/SaturationPropsFromDeck.hpp index a4667f8fb..2ea757d61 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck.hpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck.hpp @@ -36,33 +36,21 @@ struct UnstructuredGrid; namespace Opm { - - - /// Interface to saturation functions from deck. - /// Possible values for template argument (for now): - /// SatFuncSetStone2Nonuniform, - /// SatFuncSetStone2Uniform. - /// SatFuncSetSimpleNonuniform, - /// SatFuncSetSimpleUniform. - template class SaturationPropsFromDeck : public SaturationPropsInterface { public: /// Default constructor. - SaturationPropsFromDeck(); + inline SaturationPropsFromDeck(); /// Initialize from deck and grid. /// \param[in] deck Deck input parser /// \param[in] grid Grid to which property object applies, needed for the /// mapping from cell indices (typically from a processed grid) /// to logical cartesian indices consistent with the deck. - /// \param[in] samples Number of uniform sample points for saturation tables. - /// NOTE: samples will only be used with the SatFuncSetUniform template argument. - void init(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclipseState, - const UnstructuredGrid& grid, - const int samples); + inline void init(Opm::DeckConstPtr deck, + Opm::EclipseStateConstPtr eclipseState, + const UnstructuredGrid& grid); /// Initialize from deck and grid. /// \param[in] deck Deck input parser @@ -75,19 +63,16 @@ namespace Opm /// global cell indices used in the deck. /// \param[in] begin_cell_centroids Pointer to the first cell_centroid of the grid. /// \param[in] dimensions The dimensions of the grid. - /// \param[in] samples Number of uniform sample points for saturation tables. - /// NOTE: samples will only be used with the SatFuncSetUniform template argument. template - void init(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclipseState, - int number_of_cells, - const int* global_cell, - const T& begin_cell_centroids, - int dimensions, - const int samples); + inline void init(Opm::DeckConstPtr deck, + Opm::EclipseStateConstPtr eclipseState, + int number_of_cells, + const int* global_cell, + const T& begin_cell_centroids, + int dimensions); /// \return P, the number of phases. - int numPhases() const; + inline int numPhases() const; /// Relative permeability. /// \param[in] n Number of data points. @@ -98,11 +83,11 @@ namespace Opm /// The P^2 derivative matrix is /// m_{ij} = \frac{dkr_i}{ds^j}, /// and is output in Fortran order (m_00 m_10 m_20 m01 ...) - void relperm(const int n, - const double* s, - const int* cells, - double* kr, - double* dkrds) const; + inline void relperm(const int n, + const double* s, + const int* cells, + double* kr, + double* dkrds) const; /// Capillary pressure. /// \param[in] n Number of data points. @@ -113,37 +98,39 @@ namespace Opm /// The P^2 derivative matrix is /// m_{ij} = \frac{dpc_i}{ds^j}, /// and is output in Fortran order (m_00 m_10 m_20 m01 ...) - void capPress(const int n, - const double* s, - const int* cells, - double* pc, - double* dpcds) const; + inline void capPress(const int n, + const double* s, + const int* cells, + double* pc, + double* dpcds) const; /// Obtain the range of allowable saturation values. /// \param[in] n Number of data points. /// \param[out] smin Array of nP minimum s values, array must be valid before calling. /// \param[out] smax Array of nP maximum s values, array must be valid before calling. - void satRange(const int n, - const int* cells, - double* smin, - double* smax) const; + inline void satRange(const int n, + const int* cells, + double* smin, + double* smax) const; /// Update saturation state for the hysteresis tracking /// \param[in] n Number of data points. /// \param[in] s Array of nP saturation values. - void updateSatHyst(const int n, - const int* cells, - const double* s); + inline void updateSatHyst(const int n, + const int* cells, + const double* s); /// Update capillary pressure scaling according to pressure diff. and initial water saturation. /// \param[in] cell Cell index. /// \param[in] pcow P_oil - P_water. /// \param[in/out] swat Water saturation. / Possibly modified Water saturation. - void swatInitScaling(const int cell, - const double pcow, - double & swat); + inline void swatInitScaling(const int cell, + const double pcow, + double & swat); private: + typedef SatFuncGwsegNonuniform SatFuncSet; + PhaseUsage phase_usage_; std::vector satfuncset_; std::vector cell_to_func_; // = SATNUM - 1 @@ -158,7 +145,7 @@ namespace Opm typedef SatFuncSet Funcs; - const Funcs& funcForCell(const int cell) const; + inline const Funcs& funcForCell(const int cell) const; template void initEPS(Opm::DeckConstPtr deck, Opm::EclipseStateConstPtr eclipseState, diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp index ed03ceb2f..8b79b7bce 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp @@ -41,39 +41,36 @@ namespace Opm /// Default constructor. - template - SaturationPropsFromDeck::SaturationPropsFromDeck() + inline + SaturationPropsFromDeck::SaturationPropsFromDeck() { } /// Initialize from deck. - template - void SaturationPropsFromDeck::init(Opm::DeckConstPtr deck, + inline + void SaturationPropsFromDeck::init(Opm::DeckConstPtr deck, Opm::EclipseStateConstPtr eclipseState, - const UnstructuredGrid& grid, - const int samples) + const UnstructuredGrid& grid) { this->init(deck, eclipseState, grid.number_of_cells, grid.global_cell, grid.cell_centroids, - grid.dimensions, samples); + grid.dimensions); } /// Initialize from deck. - template template - void SaturationPropsFromDeck::init(Opm::DeckConstPtr deck, + void SaturationPropsFromDeck::init(Opm::DeckConstPtr deck, Opm::EclipseStateConstPtr eclipseState, int number_of_cells, const int* global_cell, const T& begin_cell_centroids, - int dimensions, - const int samples) + int dimensions) { phase_usage_ = phaseUsageFromDeck(deck); // Extract input data. // Oil phase should be active. - if (!phase_usage_.phase_used[Liquid]) { + if (!phase_usage_.phase_used[BlackoilPhases::Liquid]) { OPM_THROW(std::runtime_error, "SaturationPropsFromDeck::init() -- oil phase must be active."); } @@ -93,11 +90,11 @@ namespace Opm // Obtain SATNUM, if it exists, and create cell_to_func_. // Otherwise, let the cell_to_func_ mapping be just empty. int satfuncs_expected = 1; + cell_to_func_.resize(number_of_cells, /*value=*/0); if (deck->hasKeyword("SATNUM")) { const std::vector& satnum = deck->getKeyword("SATNUM")->getIntData(); satfuncs_expected = *std::max_element(satnum.begin(), satnum.end()); const int num_cells = number_of_cells; - cell_to_func_.resize(num_cells); const int* gc = global_cell; for (int cell = 0; cell < num_cells; ++cell) { const int deck_pos = (gc == NULL) ? cell : gc[cell]; @@ -108,13 +105,13 @@ namespace Opm // Find number of tables, check for consistency. enum { Uninitialized = -1 }; int num_tables = Uninitialized; - if (phase_usage_.phase_used[Aqua]) { + if (phase_usage_.phase_used[BlackoilPhases::Aqua]) { num_tables = deck->getKeyword("SWOF")->size(); if (num_tables < satfuncs_expected) { OPM_THROW(std::runtime_error, "Found " << num_tables << " SWOF tables, SATNUM specifies at least " << satfuncs_expected); } } - if (phase_usage_.phase_used[Vapour]) { + if (phase_usage_.phase_used[BlackoilPhases::Vapour]) { int num_sgof_tables = deck->getKeyword("SGOF")->size(); if (num_sgof_tables < satfuncs_expected) { OPM_THROW(std::runtime_error, "Found " << num_tables << " SGOF tables, SATNUM specifies at least " << satfuncs_expected); @@ -129,7 +126,7 @@ namespace Opm // Initialize tables. satfuncset_.resize(num_tables); for (int table = 0; table < num_tables; ++table) { - satfuncset_[table].init(eclipseState, table, phase_usage_, samples); + satfuncset_[table].init(eclipseState, table, phase_usage_, -1); } // Check EHYSTR status @@ -249,8 +246,8 @@ namespace Opm /// \return P, the number of phases. - template - int SaturationPropsFromDeck::numPhases() const + inline + int SaturationPropsFromDeck::numPhases() const { return phase_usage_.num_phases; } @@ -268,8 +265,8 @@ namespace Opm /// The P^2 derivative matrix is /// m_{ij} = \frac{dkr_i}{ds^j}, /// and is output in Fortran order (m_00 m_10 m_20 m01 ...) - template - void SaturationPropsFromDeck::relperm(const int n, + inline + void SaturationPropsFromDeck::relperm(const int n, const double* s, const int* cells, double* kr, @@ -316,8 +313,8 @@ namespace Opm /// The P^2 derivative matrix is /// m_{ij} = \frac{dpc_i}{ds^j}, /// and is output in Fortran order (m_00 m_10 m_20 m01 ...) - template - void SaturationPropsFromDeck::capPress(const int n, + inline + void SaturationPropsFromDeck::capPress(const int n, const double* s, const int* cells, double* pc, @@ -355,8 +352,8 @@ namespace Opm /// \param[in] cells Array of n cell indices. /// \param[out] smin Array of nP minimum s values, array must be valid before calling. /// \param[out] smax Array of nP maximum s values, array must be valid before calling. - template - void SaturationPropsFromDeck::satRange(const int n, + inline + void SaturationPropsFromDeck::satRange(const int n, const int* cells, double* smin, double* smax) const @@ -405,8 +402,8 @@ namespace Opm /// Update saturation state for the hysteresis tracking /// \param[in] n Number of data points. /// \param[in] s Array of nP saturation values. - template - void SaturationPropsFromDeck::updateSatHyst(const int n, + inline + void SaturationPropsFromDeck::updateSatHyst(const int n, const int* cells, const double* s) { @@ -426,8 +423,8 @@ namespace Opm /// \param[in] cell Cell index. /// \param[in] pcow P_oil - P_water. /// \param[in/out] swat Water saturation. / Possibly modified Water saturation. - template - void SaturationPropsFromDeck::swatInitScaling(const int cell, + inline + void SaturationPropsFromDeck::swatInitScaling(const int cell, const double pcow, double& swat) { @@ -456,17 +453,15 @@ namespace Opm // Map the cell number to the correct function set. - template - const typename SaturationPropsFromDeck::Funcs& - SaturationPropsFromDeck::funcForCell(const int cell) const + inline const SaturationPropsFromDeck::SatFuncSet& + SaturationPropsFromDeck::funcForCell(const int cell) const { return cell_to_func_.empty() ? satfuncset_[0] : satfuncset_[cell_to_func_[cell]]; } // Initialize saturation scaling parameters - template template - void SaturationPropsFromDeck::initEPS(Opm::DeckConstPtr deck, + void SaturationPropsFromDeck::initEPS(Opm::DeckConstPtr deck, Opm::EclipseStateConstPtr eclipseState, int number_of_cells, const int* global_cell, @@ -542,9 +537,8 @@ namespace Opm } // Initialize saturation scaling parameter - template template - void SaturationPropsFromDeck::initEPSKey(Opm::DeckConstPtr deck, + void SaturationPropsFromDeck::initEPSKey(Opm::DeckConstPtr deck, Opm::EclipseStateConstPtr eclipseState, int number_of_cells, const int* global_cell, @@ -738,8 +732,8 @@ namespace Opm } // Saturation scaling - template - void SaturationPropsFromDeck::initEPSParam(const int cell, + inline + void SaturationPropsFromDeck::initEPSParam(const int cell, EPSTransforms::Transform& data, const bool oil, // flag indicating krow/krog calculations const double sl_tab, // minimum saturation (for krow/krog calculations this is normally zero)