Adds Opm::EclIO::SummaryNode::is_user_defined().

This commit is contained in:
Williham Williham Totland 2020-03-20 11:54:19 +01:00
parent 62983db22f
commit 327fe79c90
2 changed files with 40 additions and 0 deletions

View File

@ -51,6 +51,7 @@ struct SummaryNode {
constexpr static int default_number { std::numeric_limits<int>::min() };
std::string unique_key() const;
bool is_user_defined() const;
};
} // namespace Opm::EclIO

View File

@ -17,6 +17,9 @@
*/
#include <numeric>
#include <regex>
#include <string>
#include <unordered_set>
#include <vector>
#include <opm/io/eclipse/SummaryNode.hpp>
@ -71,3 +74,39 @@ std::string Opm::EclIO::SummaryNode::unique_key() const {
return std::accumulate(std::begin(key_parts), std::end(key_parts), std::string(), compose_key);
}
bool Opm::EclIO::SummaryNode::is_user_defined() const {
static const std::unordered_set<std::string> udq_blacklist {
"AUTOCOAR",
"AUTOREF",
"FULLIMP",
"GUIDECAL",
"GUIDERAT",
"GUPFREQ",
"RUNSPEC",
"RUNSUM",
"SUMMARY",
"SUMTHIN",
"SURF",
"SURFACT",
"SURFACTW",
"SURFADDW",
"SURFADS",
"SURFCAPD",
"SURFESAL",
"SURFNUM",
"SURFOPTS",
"SURFROCK",
"SURFST",
"SURFSTES",
"SURFVISC",
"SURFWNUM",
} ;
static const std::regex user_defined_regex { "[ABCFGRSW]U[A-Z]+" } ;
const bool matched { std::regex_match(keyword, user_defined_regex) } ;
const bool blacklisted { udq_blacklist.find(keyword) != udq_blacklist.end() } ;
return matched && !blacklisted;
}