Fix access to keywords, while still silencing warning.

Previous fix was wrong because it called getKeyword() outside the
hasKeyword() check. Current version (like original code) uses the
short-circuiting behaviour of && to ensure this.
This commit is contained in:
Atgeirr Flø Rasmussen 2014-04-15 14:52:21 +02:00 committed by Andreas Lauser
parent 91dedb0eea
commit c8d13d2a79

View File

@ -525,8 +525,8 @@ namespace Opm
for (size_t i = 0; i < rec.size(); ++i) { for (size_t i = 0; i < rec.size(); ++i) {
const int cell = *(eqlmap.cells(i).begin()); const int cell = *(eqlmap.cells(i).begin());
if (rec[i].live_oil_table_index > 0) { if (rec[i].live_oil_table_index > 0) {
const int tab_size = newParserDeck->getKeyword("RSVD")->size(); if (newParserDeck->hasKeyword("RSVD") &&
if (newParserDeck->hasKeyword("RSVD") && rec[i].live_oil_table_index <= tab_size) { size_t(rec[i].live_oil_table_index) <= newParserDeck->getKeyword("RSVD")->size()) {
Opm::SimpleTable rsvd(newParserDeck->getKeyword("RSVD"),std::vector<std::string>{"vd", "rs"},rec[i].live_oil_table_index-1); Opm::SimpleTable rsvd(newParserDeck->getKeyword("RSVD"),std::vector<std::string>{"vd", "rs"},rec[i].live_oil_table_index-1);
std::vector<double> vd(rsvd.getColumn("vd")); std::vector<double> vd(rsvd.getColumn("vd"));
std::vector<double> rs(rsvd.getColumn("rs")); std::vector<double> rs(rsvd.getColumn("rs"));
@ -556,8 +556,8 @@ namespace Opm
for (size_t i = 0; i < rec.size(); ++i) { for (size_t i = 0; i < rec.size(); ++i) {
const int cell = *(eqlmap.cells(i).begin()); const int cell = *(eqlmap.cells(i).begin());
if (rec[i].wet_gas_table_index > 0) { if (rec[i].wet_gas_table_index > 0) {
const int tab_size = newParserDeck->getKeyword("RVVD")->size(); if (newParserDeck->hasKeyword("RVVD") &&
if (newParserDeck->hasKeyword("RVVD") && rec[i].wet_gas_table_index <= tab_size) { size_t(rec[i].wet_gas_table_index) <= newParserDeck->getKeyword("RVVD")->size()) {
Opm::SimpleTable rvvd(newParserDeck->getKeyword("RVVD"),std::vector<std::string>{"vd", "rv"},rec[i].wet_gas_table_index-1); Opm::SimpleTable rvvd(newParserDeck->getKeyword("RVVD"),std::vector<std::string>{"vd", "rv"},rec[i].wet_gas_table_index-1);
std::vector<double> vd(rvvd.getColumn("vd")); std::vector<double> vd(rvvd.getColumn("vd"));
std::vector<double> rv(rvvd.getColumn("rv")); std::vector<double> rv(rvvd.getColumn("rv"));