diff --git a/opm/parser/eclipse/EclipseState/EclipseState.cpp b/opm/parser/eclipse/EclipseState/EclipseState.cpp index 1ba63e8bd..01a618cfb 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.cpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.cpp @@ -537,6 +537,7 @@ namespace Opm { double nan = std::numeric_limits::quiet_NaN(); const auto eptLookup = std::make_shared>(*deck, *this); + const auto tempLookup = std::make_shared>(*deck, *this); const auto distributeTopLayer = std::make_shared(*this); const auto initPORV = std::make_shared(*this); @@ -678,6 +679,9 @@ namespace Opm { SupportedDoubleKeywordInfo( "ISWCRZ" , eptLookup, "1" ), SupportedDoubleKeywordInfo( "ISWCRZ-" , eptLookup, "1" ), + // cell temperature (E300 only, but makes a lot of sense for E100, too) + SupportedDoubleKeywordInfo( "TEMPI" , tempLookup, "Temperature" ), + // porosity SupportedDoubleKeywordInfo( "PORO" , nan, distributeTopLayer , "1" ), diff --git a/opm/parser/eclipse/EclipseState/Grid/GridPropertyInitializers.hpp b/opm/parser/eclipse/EclipseState/Grid/GridPropertyInitializers.hpp index a05b476da..50ea60464 100644 --- a/opm/parser/eclipse/EclipseState/Grid/GridPropertyInitializers.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/GridPropertyInitializers.hpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -349,6 +350,51 @@ private: const Deck& m_deck; const EclipseState& m_eclipseState; }; + +// initialize the TEMPI grid property using the temperature vs depth +// table (stemming from the TEMPVD or the RTEMPVD keyword) +template +class GridPropertyTemperatureLookupInitializer + : public GridPropertyBaseInitializer +{ +public: + GridPropertyTemperatureLookupInitializer(const Deck& deck, const EclipseState& eclipseState) + : m_deck(deck) + , m_eclipseState(eclipseState) + { } + + void apply(std::vector& values, + const std::string& propertyName) const + { + if (propertyName != "TEMPI") + throw std::logic_error("The TemperatureLookupInitializer can only be used for the initial temperature!"); + + if (!m_deck.hasKeyword("EQLNUM")) { + // if values are defaulted in the TEMPI keyword, but no + // EQLNUM is specified, you will get NaNs... + double nan = std::numeric_limits::quiet_NaN(); + std::fill(values.begin(), values.end(), nan); + return; + } + + auto eclipseGrid = m_eclipseState.getEclipseGrid(); + const std::vector& rtempvdTables = m_eclipseState.getRtempvdTables(); + const std::vector& eqlNum = m_eclipseState.getIntGridProperty("EQLNUM")->getData(); + + for (int cellIdx = 0; cellIdx < eqlNum.size(); ++ cellIdx) { + int cellEquilNum = eqlNum[cellIdx]; + const RtempvdTable& rtempvdTable = rtempvdTables[cellEquilNum]; + double cellDepth = std::get<2>(eclipseGrid->getCellCenter(cellIdx)); + values[cellIdx] = rtempvdTable.evaluate("Temperature", cellDepth); + } + } + +private: + const Deck& m_deck; + const EclipseState& m_eclipseState; +}; + } #endif