Add fip regioin name to summaryconfig node

This commit is contained in:
Joakim Hove 2020-08-27 07:57:28 +02:00
parent 49460edf39
commit 5976efa953
3 changed files with 55 additions and 12 deletions

View File

@ -51,6 +51,7 @@ namespace Opm {
SummaryConfigNode& namedEntity(std::string name);
SummaryConfigNode& number(const int num);
SummaryConfigNode& isUserDefined(const bool userDefined);
SummaryConfigNode& fip_region(const std::string& fip_region);
const std::string& keyword() const { return this->keyword_; }
Category category() const { return this->category_; }
@ -58,12 +59,13 @@ namespace Opm {
const std::string& namedEntity() const { return this->name_; }
int number() const { return this->number_; }
bool isUserDefined() const { return this->userDefined_; }
const std::string& fip_region() const { return this->fip_region_; }
std::string uniqueNodeKey() const;
const Location& location( ) const { return this->loc; }
operator Opm::EclIO::SummaryNode() const {
return { keyword_, category_, type_, name_, number_ };
return { keyword_, category_, type_, name_, number_, fip_region_ };
}
template<class Serializer>
@ -75,6 +77,7 @@ namespace Opm {
serializer(type_);
serializer(name_);
serializer(number_);
serializer(fip_region_);
serializer(userDefined_);
}
@ -85,6 +88,7 @@ namespace Opm {
Type type_{ Type::Undefined };
std::string name_{};
int number_{std::numeric_limits<int>::min()};
std::string fip_region_;
bool userDefined_{false};
};

View File

@ -460,19 +460,25 @@ inline void keywordR2R( SummaryConfig::keyword_list& /* list */,
}
inline void keywordR( SummaryConfig::keyword_list& list,
const DeckKeyword& keyword,
const TableManager& tables,
const ParseContext& parseContext,
ErrorGuard& errors ) {
inline void keywordR( SummaryConfig::keyword_list& list,
const DeckKeyword& deck_keyword,
const TableManager& tables,
const ParseContext& parseContext,
ErrorGuard& errors ) {
if( is_region_to_region(keyword.name()) ) {
keywordR2R( list, parseContext, errors, keyword );
auto keyword = deck_keyword.name();
if( is_region_to_region(keyword) ) {
keywordR2R( list, parseContext, errors, deck_keyword );
return;
}
std::string region_name = "FIPNUM";
if (keyword.size() > 5) {
auto dash_pos = keyword.find("_");
region_name = "FIP" + keyword.substr(5,3);
}
const size_t numfip = tables.numFIPRegions( );
const auto& item = keyword.getDataRecord().getDataItem();
const auto& item = deck_keyword.getDataRecord().getDataItem();
std::vector<int> regions;
if (item.data_size() > 0)
@ -482,11 +488,11 @@ inline void keywordR2R( SummaryConfig::keyword_list& /* list */,
regions.push_back( region );
}
// Don't (currently) need parameter type for region keywords
auto param = SummaryConfigNode {
keyword.name(), SummaryConfigNode::Category::Region, keyword.location()
keyword, SummaryConfigNode::Category::Region, deck_keyword.location()
}
.isUserDefined( is_udq(keyword.name()) );
.fip_region( region_name )
.isUserDefined( is_udq(keyword) );
for( const int region : regions ) {
if (region >= 1 && region <= static_cast<int>(numfip))
@ -872,6 +878,12 @@ SummaryConfigNode SummaryConfigNode::serializeObject()
return result;
}
SummaryConfigNode& SummaryConfigNode::fip_region(const std::string& fip_region)
{
this->fip_region_ = fip_region;
return *this;
}
SummaryConfigNode& SummaryConfigNode::parameterType(const Type type)
{
this->type_ = type;

View File

@ -21,6 +21,7 @@
#include <boost/test/unit_test.hpp>
#include <opm/io/eclipse/SummaryNode.hpp>
#include <opm/parser/eclipse/Python/Python.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
@ -96,6 +97,8 @@ static Deck createDeck( const std::string& summary ) {
"REGIONS\n"
"FIPNUM\n"
"200*1 300*2 500*3 /\n"
"FIPREG\n"
"200*10 300*20 500*30 /\n"
"SCHEDULE\n"
"WELSPECS\n"
" \'W_1\' \'OP\' 1 1 3.33 \'OIL\' 7* / \n"
@ -1037,3 +1040,27 @@ RUNSUM
BOOST_CHECK( summary_config2.createRunSummary());
BOOST_CHECK(!summary_config2.hasKeyword("RUNSUM"));
}
BOOST_AUTO_TEST_CASE(FIPREG) {
std::string deck_string = R"(
RPR__REG
/
ROPT_REG
/
)";
const auto& summary_config = createSummary(deck_string);
BOOST_CHECK(summary_config.hasKeyword("RPR__REG"));
BOOST_CHECK(summary_config.hasKeyword("ROPT_REG"));
for (const auto& node : summary_config) {
if (node.category() == EclIO::SummaryNode::Category::Region)
BOOST_CHECK_EQUAL( node.fip_region(), "FIPREG" );
}
const auto& fip_regions = summary_config.fip_regions();
BOOST_CHECK_EQUAL(fip_regions.size(), 1);
auto reg_iter = fip_regions.find("FIPREG");
BOOST_CHECK( reg_iter != fip_regions.end() );
}