From a9e51eeb424bcd22ecd142fa631327e7b2666baa Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 18 Jul 2016 12:32:28 +0800 Subject: [PATCH] treat partially supported options by different multimap. --- opm/autodiff/MissingFeatures.cpp | 88 ++++++++++++++------------------ 1 file changed, 39 insertions(+), 49 deletions(-) diff --git a/opm/autodiff/MissingFeatures.cpp b/opm/autodiff/MissingFeatures.cpp index 05a69120c..539fd7568 100644 --- a/opm/autodiff/MissingFeatures.cpp +++ b/opm/autodiff/MissingFeatures.cpp @@ -22,12 +22,30 @@ #include #include #include +#include namespace Opm { namespace MissingFeatures { + template + struct PartiallySupported { + int item; + T item_value; + }; + + std::multimap > + string_options = { {"COMPORD", PartiallySupported{1, "TRACK"}}, + {"ENDSCALE",PartiallySupported{0, "NODIR"}}, + {"ENDSCALE",PartiallySupported{1, "REVER"}}, + {"PINCH", PartiallySupported{1, "GAP"}}, + {"PINCH", PartiallySupported{3, "TOPBOT"}} + }; + + std::multimap > + int_options = { {"EHYSTR", PartiallySupported{1, 0}}}; + void checkKeywords(const Deck& deck) { // These keywords are supported by opm-parser, but are not supported @@ -67,58 +85,30 @@ namespace MissingFeatures { OpmLog::error(msg); } - // check for partially supported options. - if (keyword.name() == "COMPORD") { - for (unsigned recordIdx = 0; recordIdx < keyword.size(); ++recordIdx) { - const auto& record = keyword.getRecord(recordIdx); - if (record.getItem("ORDER_TYPE").getTrimmedString(0) != "TRACK") { - std::string msg = std::string("For keyword 'COMPORD' only 'TRACK' in second item is supported by flow.\n") - + "In file " + keyword.getFileName() + ", line " + std::to_string(keyword.getLineNumber()) + "\n"; - OpmLog::error(msg); - } + // check for partially supported keywords. + std::multimap>::iterator string_it, string_low, string_up; + string_low = string_options.lower_bound(keyword.name()); + string_up = string_options.upper_bound(keyword.name()); + for (string_it = string_low; string_it != string_up; ++string_it) { + const auto& record = keyword.getRecord(0); + if (record.getItem(string_it->second.item).get(0) != string_it->second.item_value) { + std::string msg = "For keyword '" + string_it->first + "' only value " + string_it->second.item_value + " in item " + + std::to_string(string_it->second.item + 1) + " is supported by flow.\n" + + "In file " + keyword.getFileName() + ", line " + std::to_string(keyword.getLineNumber()) + "\n"; + OpmLog::error(msg); } } - if (keyword.name() == "EHYSTR") { - for (unsigned recordIdx = 0; recordIdx < keyword.size(); ++recordIdx) { - const auto& record = keyword.getRecord(recordIdx); - if (record.getItem(1).get(0) != 0) { - std::string msg = std::string("For keyword 'EHYSTR' only Carlson kr hystersis model is supported by flow.\n") - + "In file " + keyword.getFileName() + ", line " + std::to_string(keyword.getLineNumber()) + "\n"; - OpmLog::error(msg); - } - } - } - - if (keyword.name() == "ENDSCALE") { - for (unsigned recordIdx = 0; recordIdx < keyword.size(); ++recordIdx) { - const auto& record = keyword.getRecord(recordIdx); - if (record.getItem(0).getTrimmedString(0) == "DIRECT") { - std::string msg = std::string("For keyword 'ENDSCALE', 'DIRECT' in first item is not supported by flow.\n") - + "In file " + keyword.getFileName() + ", line " + std::to_string(keyword.getLineNumber()) + "\n"; - OpmLog::error(msg); - } - if (record.getItem(1).getTrimmedString(0) == "IRREVERS") { - std::string msg = std::string("For keyword 'ENDSCALE', 'IRREVERS' in second item is not supported by flow.\n") - + "In file " + keyword.getFileName() + ", line " + std::to_string(keyword.getLineNumber()) + "\n"; - OpmLog::error(msg); - } - } - } - - if (keyword.name() == "PINCH") { - for (unsigned recordIdx = 0; recordIdx < keyword.size(); ++recordIdx) { - const auto& record = keyword.getRecord(recordIdx); - if (record.getItem(1).getTrimmedString(0) != "GAP") { - std::string msg = std::string("For keyword 'PINCH' only 'GAP' in second item is supported by flow.\n") - + "In file " + keyword.getFileName() + ", line " + std::to_string(keyword.getLineNumber()) + "\n"; - OpmLog::error(msg); - } - if (record.getItem(3).getTrimmedString(0) != "TOPBOT") { - std::string msg = std::string("For keyword 'PINCH' only 'TOPBOT' in fourth item is supported by flow.\n") - + "In file " + keyword.getFileName() + ", line " + std::to_string(keyword.getLineNumber()) + "\n"; - OpmLog::error(msg); - } + std::multimap>::iterator int_it, int_low, int_up; + int_low = int_options.lower_bound(keyword.name()); + int_up = int_options.upper_bound(keyword.name()); + for (int_it = int_low; int_it != int_up; ++int_it) { + const auto& record = keyword.getRecord(0); + if (record.getItem(int_it->second.item).get(0) != int_it->second.item_value) { + std::string msg = "For keyword '" + int_it->first + "' only value " + std::to_string(int_it->second.item_value) + " in item " + + std::to_string(int_it->second.item + 1) + " is supported by flow.\n" + + "In file " + keyword.getFileName() + ", line " + std::to_string(keyword.getLineNumber()) + "\n"; + OpmLog::error(msg); } } }