diff --git a/opm/core/simulator/SimulatorState.cpp b/opm/core/simulator/SimulatorState.cpp index 94d8b0fa..68faf8af 100644 --- a/opm/core/simulator/SimulatorState.cpp +++ b/opm/core/simulator/SimulatorState.cpp @@ -63,3 +63,42 @@ SimulatorState::registerFaceData( const std::string& name, const int components, return pos ; } +template void +SimulatorState::setFirstSat(const std::vector& cells, + const Props& props, + ExtremalSat es) +{ + if (cells.empty()) { + return; + } + int n = cells.size(); + std::vector smin(num_phases_*n); + std::vector smax(num_phases_*n); + props.satRange(n, &cells[0], &smin[0], &smax[0]); + std::vector< double >& sat = saturation(); + const double* svals = (es == MinSat) ? &smin[0] : &smax[0]; + for (int ci = 0; ci < n; ++ci) { + const int cell = cells[ci]; + sat[num_phases_*cell] = svals[num_phases_*ci]; + sat[num_phases_*cell + 1] = 1.0 - sat[num_phases_*cell]; + } +} + +// template instantiations for all known (to this library) subclasses +// of SimulatorState that will call this method. notice that there are +// no empty angle brackets after "template" -- that would have been +// specialization instead +#include +#include + +template void +SimulatorState::setFirstSat ( + const std::vector &cells, + const IncompPropertiesInterface &props, + ExtremalSat es); + +template void +SimulatorState::setFirstSat ( + const std::vector &cells, + const BlackoilPropertiesInterface &props, + ExtremalSat es); diff --git a/opm/core/simulator/SimulatorState.hpp b/opm/core/simulator/SimulatorState.hpp index 6748454d..3487d711 100644 --- a/opm/core/simulator/SimulatorState.hpp +++ b/opm/core/simulator/SimulatorState.hpp @@ -17,6 +17,8 @@ namespace Opm virtual void init(int number_of_cells, int number_of_faces, int num_phases); + enum ExtremalSat { MinSat, MaxSat }; + protected: /// \brief pressure per cell. static const int pressureId_ = 0; @@ -30,6 +32,18 @@ namespace Opm /// \brief The fluxes at the faces. static const int faceFluxId_ = 1; + /** + * Initialize the first saturation to maximum value. This method + * should be considered deprecated. Avoid to use it! + * + * \tparam Props Fluid and rock properties that pertain to this + * kind of simulation. Currently, only Blackoil- + * and IncompPropertiesInterface are supported. + */ + template + void setFirstSat(const std::vector& cells, + const Props& props, + ExtremalSat es); public: int numPhases() const { return num_phases_; } int numCells () const { return num_cells_; }