Match Region Sets by Unique Prefix

This commit switches the region set tag matching algorithm to using
unique prefixes.  This enables the simulator to recognise that the
region set name

    FIPUNI

should match up with the user defined region set 'FIPUNIT'.  In the
current master sources, the above summary vector would produce a
diagnostic message saying that the region set 'FIPUNI' (without the
final 'T') does not exist.

To this end, we instruct the ParallelEclipseState to always pass the
six character substring beginning with 'FIP' for FIP-like region
arrays and defer to the rank-0 EclipseState/FieldProps mechanism to
match this prefix with its canonical region set.
This commit is contained in:
Bård Skaflestad 2023-09-13 18:40:31 +02:00
parent 326d63cb8e
commit 85bb525067

View File

@ -24,6 +24,15 @@
#include <opm/common/ErrorMacros.hpp>
#include <cstddef>
#include <regex>
#include <string>
namespace {
bool is_FIP(const std::string& keyword)
{
return std::regex_match(keyword, std::regex { "FIP[A-Z0-9]{1,5}" });
}
}
namespace Opm {
@ -108,12 +117,16 @@ std::vector<int> ParallelFieldPropsManager::get_global_int(const std::string& ke
std::vector<int> result;
int exceptionThrown{};
if (m_comm.rank() == 0)
{
try
{
result = m_manager.get_global_int(keyword);
}catch(std::exception& e) {
if (m_comm.rank() == 0) {
try {
// Recall: FIP* keywords are special. We care only about the
// first three characters of the name following the initial
// three-character "FIP" prefix, hence "substr(0, 6)".
result = is_FIP(keyword)
? this->m_manager.get_global_int(keyword.substr(0, 6))
: this->m_manager.get_global_int(keyword);
}
catch (std::exception& e) {
exceptionThrown = 1;
OpmLog::error("No integer property field: " + keyword + " ("+e.what()+")");
m_comm.broadcast(&exceptionThrown, 1, 0);