diff --git a/opm/core/eclipse/EclipseGridParser.cpp b/opm/core/eclipse/EclipseGridParser.cpp index fef38c44..7c7962b7 100644 --- a/opm/core/eclipse/EclipseGridParser.cpp +++ b/opm/core/eclipse/EclipseGridParser.cpp @@ -118,6 +118,7 @@ namespace EclipseKeywords string("PLYMAX"), string("TLMIXPAR"), string("WPOLYMER"), string("GRUPTREE"), string("GCONINJE"), string("GCONPROD"), string("WGRUPCON"), string("ENDSCALE"), string("SCALECRS"), + string("ENPTVD"), string("ENKRVD"), // The following fields only have a dummy implementation // that allows us to ignore them. string("SWFN"), diff --git a/opm/core/eclipse/EclipseGridParser.hpp b/opm/core/eclipse/EclipseGridParser.hpp index ab871c68..f09280ee 100644 --- a/opm/core/eclipse/EclipseGridParser.hpp +++ b/opm/core/eclipse/EclipseGridParser.hpp @@ -194,6 +194,8 @@ public: SPECIAL_FIELD(WGRUPCON) SPECIAL_FIELD(ENDSCALE) SPECIAL_FIELD(SCALECRS) + SPECIAL_FIELD(ENPTVD) + SPECIAL_FIELD(ENKRVD) // The following fields only have a dummy implementation // that allows us to ignore them. diff --git a/opm/core/eclipse/EclipseGridParserHelpers.hpp b/opm/core/eclipse/EclipseGridParserHelpers.hpp index 7bc0e003..20893eac 100644 --- a/opm/core/eclipse/EclipseGridParserHelpers.hpp +++ b/opm/core/eclipse/EclipseGridParserHelpers.hpp @@ -378,7 +378,10 @@ namespace } // Replace default values -1 by linear interpolation - inline void insertDefaultValues(std::vector >& table, int ncol) + inline void insertDefaultValues(std::vector >& table, + int ncol, + double defaultOut = 0.0, + bool defaultInterpolation = true) { const int sz = table[0].size(); for (int k=1; k > > table_; + std::vector mask_; + + virtual std::string name() const { + return std::string("ENPTVD"); + } + + virtual void read(std::istream & is) { + table_.resize(5); + std::vector > sub_table(5); + while (!is.eof()) { + if(is.peek() == int('/')) { + if (sub_table[0].empty() && !(table_[0].empty())) { + is >> ignoreLine; + break; + } else { + THROW("Error reading ENPTVD data - none or incomplete table."); + } + } + std::vector data(9,-1.0); + int nread = readDefaultedVectorData(is, data, 9); + if (nread != 9) { + THROW("Error reading ENPTVD data - depth and 8 saturations pr line."); + } + if (data[0] == -1.0) { + THROW("Error reading ENPTVD data - depth can not be defaulted."); + } + if ((data[4] != -1.0) || (data[5] != -1.0) || (data[6] != -1.0) || (data[8] != -1.0)) { + THROW("Error reading ENPTVD data - non-default values in column 5-7,9 not supported."); + } + sub_table[0].push_back(data[0]); //depth + sub_table[1].push_back(data[1]); //swl + sub_table[2].push_back(data[2]); //swcr + sub_table[3].push_back(data[3]); //swu + sub_table[4].push_back(data[7]); //sowcr + is >> ignoreWhitespace; + if(is.peek() == int('/')) { + is >> ignoreLine; + if (sub_table[0].size() >= 2) { + insertDefaultValues(sub_table, 5, -1.0, false); + std::vector >::iterator it_sub = sub_table.begin(); + for(std::vector > >::size_type i=0; i > >::size_type i=1; i >::size_type j=0; j >::size_type j=0; j::size_type k=0; k > >::size_type i=0; i >::size_type j=0; j::size_type k=0; k > > table_; + std::vector mask_; + + virtual std::string name() const { + return std::string("ENKRVD"); + } + + virtual void read(std::istream & is) { + table_.resize(5); + std::vector > sub_table(5); + while (!is.eof()) { + if(is.peek() == int('/')) { + if (sub_table[0].empty() && !(table_[0].empty())) { + is >> ignoreLine; + break; + } else { + THROW("Error reading ENKRVD data - none or incomplete table."); + } + } + std::vector data(8,-1.0); + int nread = readDefaultedVectorData(is, data, 8); + if (nread != 8) { + THROW("Error reading ENKRVD data - depth and 7 relperms pr line."); + } + if (data[0] == -1.0) { + THROW("Error reading ENKRVD data - depth can not be defaulted."); + } + if ((data[2] != -1.0) || (data[5] != -1.0) || (data[6] != -1.0)) { + THROW("Error reading ENKRVD data - non-default values in column 3,6-7 not supported."); + } + sub_table[0].push_back(data[0]); //depth + sub_table[1].push_back(data[1]); //krw + sub_table[2].push_back(data[3]); //kro + sub_table[3].push_back(data[4]); //krw(sowcr) + sub_table[4].push_back(data[7]); //kro(swcr) + is >> ignoreWhitespace; + if(is.peek() == int('/')) { + is >> ignoreLine; + if (sub_table[0].size() >= 2) { + insertDefaultValues(sub_table, 5, -1.0, false); + std::vector >::iterator it_sub = sub_table.begin(); + for(std::vector > >::size_type i=0; i > >::size_type i=1; i >::size_type j=0; j >::size_type j=0; j::size_type k=0; k > >::size_type i=0; i >::size_type j=0; j::size_type k=0; k void SaturationPropsFromDeck::initEPS(const EclipseGridParser& deck, - const UnstructuredGrid& grid, - const std::string& keyword, - std::vector& scaleparam) + const UnstructuredGrid& grid, + const std::string& keyword, + std::vector& scaleparam) { - - if (deck.hasField(keyword)) { + bool useKeyword = deck.hasField(keyword); + bool hasENPTVD = deck.hasField("ENPTVD"); + bool hasENKRVD = deck.hasField("ENKRVD"); + int itab = 0; + std::vector > > table_dummy; + std::vector > >& table = table_dummy; - // Active keyword assigned default values for each cell (in case of possible box-wise assignment) - scaleparam.resize(grid.number_of_cells); - int phase_pos_aqua = phase_usage_.phase_pos[BlackoilPhases::Aqua]; - if (keyword == std::string("SWCR")) { - for (int i=0; i 0) { + table = deck.getENPTVD().table_; + } + } else if (keyword[0] == 'K' && (useKeyword || hasENKRVD)) { + if (keyword == std::string("KRW")) { + if (useKeyword || deck.getENKRVD().mask_[0]) { + itab = 1; + scaleparam.resize(grid.number_of_cells); + for (int i=0; i 0) { + table = deck.getENKRVD().table_; + } + } + if (scaleparam.empty()) { + return; + } else if (useKeyword) { // Keyword values from deck std::cout << "--- Scaling parameter '" << keyword << "' assigned." << std::endl; const int* gc = grid.global_cell; @@ -326,8 +350,28 @@ namespace Opm const int deck_pos = (gc == NULL) ? c : gc[c]; scaleparam[c] = val[deck_pos]; } + } else { + std::cout << "--- Scaling parameter '" << keyword << "' assigned via "; + if (keyword[0] == 'S') + deck.getENPTVD().write(std::cout); + else + deck.getENKRVD().write(std::cout); + const double* cc = grid.cell_centroids; + const int dim = grid.dimensions; + for (int cell = 0; cell < grid.number_of_cells; ++cell) { + int jtab = cell_to_func_.empty() ? 0 : cell_to_func_[cell]; + if (table[itab][jtab][0] != -1.0) { + std::vector& depth = table[0][jtab]; + std::vector& val = table[itab][jtab]; + double zc = cc[dim*cell+dim-1]; + if (zc >= depth.front() && zc <= depth.back()) { //don't want extrap outside depth interval + scaleparam[cell] = linearInterpolation(depth, val, zc); + } + } + } } } + // Saturation scaling template