mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
#14635 Orion Events: Use well name alias for generic keywords
This commit is contained in:
1 parent
c08323c65e
commit
1336eba81d
5 files changed
+60
-6
No files matched your search
@@ -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" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user