mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
#14635 Orion Events: Use well name alias for generic keywords
This commit is contained in:
committed by
Magne Sjaastad
parent
c08323c65e
commit
1336eba81d
@@ -602,7 +602,8 @@ void RicScheduleDataGenerator::generateWellControlForWell( const RimWellEventTim
|
||||
{
|
||||
if ( event->wellName() != well.name() ) continue;
|
||||
|
||||
auto kw = RifEventKeywordFormatter::buildWellEvent( event, well.name() );
|
||||
const QString wellName = well.completionSettings() ? well.completionSettings()->wellNameForExport() : well.name();
|
||||
auto kw = RifEventKeywordFormatter::buildWellEvent( event, wellName );
|
||||
if ( !kw ) continue;
|
||||
|
||||
const QString name = QString::fromStdString( kw->name() );
|
||||
|
||||
@@ -77,7 +77,8 @@ bool RifEventKeywordFormatter::isRecordlessKeyword( const Opm::DeckKeyword& keyw
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::optional<Opm::DeckKeyword> RifEventKeywordFormatter::buildKeyword( const QString& keywordName,
|
||||
const std::vector<RimWellEventKeywordItem*>& items )
|
||||
const std::vector<RimWellEventKeywordItem*>& items,
|
||||
const std::optional<QString>& wellNameOverride )
|
||||
{
|
||||
QString keyword = keywordName.toUpper();
|
||||
std::string kwName = keyword.toStdString();
|
||||
@@ -187,7 +188,8 @@ std::optional<Opm::DeckKeyword> RifEventKeywordFormatter::buildKeyword( const QS
|
||||
std::optional<size_t> lastProvidedIdx;
|
||||
for ( size_t i = 0; i < record.size(); ++i )
|
||||
{
|
||||
if ( userItemsByName.contains( record.get( i ).name() ) ) lastProvidedIdx = i;
|
||||
const std::string& name = record.get( i ).name();
|
||||
if ( userItemsByName.contains( name ) || ( name == "WELL" && wellNameOverride.has_value() ) ) lastProvidedIdx = i;
|
||||
}
|
||||
|
||||
std::vector<Opm::DeckItem> deckItems;
|
||||
@@ -198,7 +200,9 @@ std::optional<Opm::DeckKeyword> RifEventKeywordFormatter::buildKeyword( const QS
|
||||
{
|
||||
const std::string& name = record.get( i ).name();
|
||||
auto it = userItemsByName.find( name );
|
||||
if ( it == userItemsByName.end() )
|
||||
if ( name == "WELL" && wellNameOverride.has_value() )
|
||||
deckItems.push_back( RifOpmDeckTools::item( name, wellNameOverride->toStdString() ) );
|
||||
else if ( it == userItemsByName.end() )
|
||||
deckItems.push_back( RifOpmDeckTools::defaultItem( name ) );
|
||||
else
|
||||
appendDeckItem( deckItems, name, it->second );
|
||||
@@ -361,7 +365,8 @@ std::optional<Opm::DeckKeyword> RifEventKeywordFormatter::buildWellEvent( const
|
||||
const auto* keywordEvent = dynamic_cast<const RimWellEventKeyword*>( event );
|
||||
if ( keywordEvent )
|
||||
{
|
||||
return buildKeyword( keywordEvent->keywordName(), keywordEvent->items() );
|
||||
const std::optional<QString> wellNameOverride = wellName.isEmpty() ? std::nullopt : std::optional<QString>( wellName );
|
||||
return buildKeyword( keywordEvent->keywordName(), keywordEvent->items(), wellNameOverride );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,9 @@ namespace RifEventKeywordFormatter
|
||||
bool isRecordlessKeyword( const Opm::DeckKeyword& keyword );
|
||||
|
||||
// build*: produce a structured Opm::DeckKeyword (used by callers that merge records across wells).
|
||||
std::optional<Opm::DeckKeyword> buildKeyword( const QString& keywordName, const std::vector<RimWellEventKeywordItem*>& items );
|
||||
std::optional<Opm::DeckKeyword> buildKeyword( const QString& keywordName,
|
||||
const std::vector<RimWellEventKeywordItem*>& items,
|
||||
const std::optional<QString>& wellNameOverride = std::nullopt );
|
||||
std::optional<Opm::DeckKeyword> buildWconprod( const RimWellEventControl* controlEvent, const QString& wellName );
|
||||
std::optional<Opm::DeckKeyword> buildWconinje( const RimWellEventControl* controlEvent, const QString& wellName );
|
||||
std::optional<Opm::DeckKeyword> buildWellEvent( const RimWellEvent* event, const QString& wellName );
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
|
||||
#include "RiaTestDataDirectory.h"
|
||||
|
||||
#include "RifEventKeywordFormatter.h"
|
||||
#include "RifOpmDeckTools.h"
|
||||
#include "RifOpmFlowDeckFile.h"
|
||||
|
||||
#include "RigEclipseResultTools.h"
|
||||
|
||||
#include "ProjectDataModel/Jobs/RimKeywordFactory.h"
|
||||
#include "ProjectDataModel/WellEvents/RimWellEventKeywordItem.h"
|
||||
|
||||
#include "cvfStructGrid.h"
|
||||
|
||||
@@ -755,6 +757,22 @@ TEST( RifOpmFlowDeckFileTest, SaveDeckPreservesIncludeOnlyWrapperFiles )
|
||||
EXPECT_EQ( 2, std::count( keywords.begin(), keywords.end(), std::string( "VFPPROD" ) ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RifEventKeywordFormatterTest, BuildKeywordOverridesWellName )
|
||||
{
|
||||
RimWellEventKeywordItem wellItem;
|
||||
wellItem.setItemName( "WELL" );
|
||||
wellItem.setStringValue( "WellPathA" );
|
||||
|
||||
auto keyword = RifEventKeywordFormatter::buildKeyword( "WCONHIST", { &wellItem }, QString( "ORION_EXPORT_ALIAS" ) );
|
||||
|
||||
ASSERT_TRUE( keyword.has_value() );
|
||||
ASSERT_EQ( keyword->size(), 1 );
|
||||
EXPECT_EQ( keyword->getRecord( 0 ).getItem( "WELL" ).getTrimmedString( 0 ), "ORION_EXPORT_ALIAS" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -1910,6 +1910,34 @@ class TestOrionEventsIntegration:
|
||||
assert f'Line 3 [WELL "{well.name}", date 2024-01-01]' in error_msg
|
||||
assert "Keyword 'NOT_A_KEYWORD' is not recognized by opm-common" in error_msg
|
||||
|
||||
def test_generic_well_keywords_use_export_alias(self, project_with_case_and_wells):
|
||||
project, case, timeline = project_with_case_and_wells
|
||||
well = project.well_paths()[0]
|
||||
|
||||
export_alias = "ORION_EXPORT_ALIAS"
|
||||
settings = well.completion_settings()
|
||||
settings.well_name_for_export = export_alias
|
||||
settings.update()
|
||||
|
||||
document = parse_orion_events(
|
||||
"ORIONEVENTS 2.0\n"
|
||||
f'WELL "{well.name}"\n'
|
||||
" 2024-01-01 WCONHIST STATUS=OPEN CMODE=ORAT ORAT=100\n"
|
||||
" 2024-01-01 WELTARG CMODE=ORAT VALUE=200\n"
|
||||
" 2024-01-01 WRFTPLT OUTPUT_RFT=YES OUTPUT_PLT=NO OUTPUT_SEGMENT=NO\n"
|
||||
)
|
||||
report = apply_orion_document(document, timeline, project)
|
||||
assert report.errors == []
|
||||
|
||||
schedule = timeline.generate_schedule_text(
|
||||
eclipse_case=case,
|
||||
first_date_as_comment=False,
|
||||
)
|
||||
for keyword in ("WCONHIST", "WELTARG", "WRFTPLT"):
|
||||
block = schedule.split(keyword, 1)[1].split("/", 1)[0]
|
||||
assert f"'{export_alias}'" in block
|
||||
assert f"'{well.name}'" not in block
|
||||
|
||||
def test_rptrst_boolean_values_emit_bare_mnemonics(
|
||||
self, project_with_case_and_wells
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user