Merge pull request #762 from qilicun/messages-for-keywords-options

Handle partially supported options manually.
This commit is contained in:
Atgeirr Flø Rasmussen 2016-08-23 08:07:29 +02:00 committed by GitHub
commit 183d2f4477
2 changed files with 58 additions and 2 deletions

View File

@ -17,17 +17,51 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/C.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/E.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/P.hpp>
#include <opm/autodiff/MissingFeatures.hpp>
#include <unordered_set>
#include <string>
#include <map>
#include <boost/lexical_cast.hpp>
namespace Opm {
namespace MissingFeatures {
template <typename Keyword, typename Item, typename T>
void addSupported(std::multimap<std::string, PartiallySupported<T> >& map, T itemValue)
{
std::pair<std::string,PartiallySupported<T> > pair({Keyword::keywordName, PartiallySupported<T>{Item::itemName , itemValue}});
map.insert(pair);
}
template <typename T>
void checkOptions(const DeckKeyword& keyword, std::multimap<std::string , PartiallySupported<T> >& map)
{
// check for partially supported keywords.
typename std::multimap<std::string, PartiallySupported<T> >::iterator it, itlow, itup;
itlow = map.lower_bound(keyword.name());
itup = map.upper_bound(keyword.name());
for (it = itlow; it != itup; ++it) {
const auto& record = keyword.getRecord(0);
if (record.getItem(it->second.item).template get<T>(0) != it->second.item_value) {
std::string msg = "For keyword '" + it->first + "' only value " + boost::lexical_cast<std::string>(it->second.item_value)
+ " in item " + it->second.item + " is supported by flow.\n"
+ "In file " + keyword.getFileName() + ", line " + std::to_string(keyword.getLineNumber()) + "\n";
OpmLog::warning(msg);
}
}
}
void checkKeywords(const Deck& deck)
{
// These keywords are supported by opm-parser, but are not supported
@ -55,6 +89,14 @@ namespace MissingFeatures {
"VAPPARS", "VISCREF", "WATVISCT",
"WPAVE", "WPIMULT", "WPITAB", "WTEMP",
"WTEST", "WTRACER", "ZIPPY2" };
std::multimap<std::string, PartiallySupported<std::string> > string_options;
std::multimap<std::string, PartiallySupported<int> > int_options;
addSupported<ParserKeywords::COMPORD, ParserKeywords::COMPORD::ORDER_TYPE, std::string>(string_options , "DEPTH");
addSupported<ParserKeywords::ENDSCALE, ParserKeywords::ENDSCALE::DIRECT, std::string>(string_options, "NODIR");
addSupported<ParserKeywords::ENDSCALE, ParserKeywords::ENDSCALE::IRREVERS, std::string>(string_options, "REVER");
addSupported<ParserKeywords::PINCH, ParserKeywords::PINCH::CONTROL_OPTION, std::string>(string_options, "GAP");
addSupported<ParserKeywords::PINCH, ParserKeywords::PINCH::PINCHOUT_OPTION, std::string>(string_options, "TOPBOT");
addSupported<ParserKeywords::EHYSTR, ParserKeywords::EHYSTR::relative_perm_hyst, int>(int_options , 0);
// check deck and keyword for flow and parser.
for (size_t idx = 0; idx < deck.size(); ++idx) {
@ -64,8 +106,10 @@ namespace MissingFeatures {
if (it != unsupported_keywords.end()) {
std::string msg = "Keyword '" + keyword.name() + "' is not supported by flow.\n"
+ "In file " + keyword.getFileName() + ", line " + std::to_string(keyword.getLineNumber()) + "\n";
OpmLog::error(msg);
OpmLog::warning(msg);
}
checkOptions<std::string>(keyword, string_options);
checkOptions<int>(keyword, int_options);
}
}
} // namespace MissingFeatures

View File

@ -24,6 +24,18 @@ namespace Opm {
namespace MissingFeatures {
template <typename T>
struct PartiallySupported {
std::string item;
T item_value;
};
template <typename Keyword, typename Item, typename T>
void addSupported(std::multimap<std::string, PartiallySupported<T> >& map, T itemValue);
template <typename T>
void checkOptions(const DeckKeyword& keyword, std::multimap<std::string , PartiallySupported<T> >& map);
void checkKeywords(const Deck& deck);
}