Merge pull request #4818 from OPM/improve-ensemble-stepping

Improve ensemble stepping
This commit is contained in:
Magne Sjaastad 2019-10-04 11:43:06 +02:00 committed by GitHub
commit a6733ae776
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 120 additions and 127 deletions

View File

@ -34,7 +34,7 @@ RiaSummaryCurveAnalyzer::RiaSummaryCurveAnalyzer() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveAnalyzer::appendAdresses( const std::vector<RifEclipseSummaryAddress>& allAddresses )
void RiaSummaryCurveAnalyzer::appendAddresses( const std::vector<RifEclipseSummaryAddress>& allAddresses )
{
for ( const auto& adr : allAddresses )
{
@ -45,7 +45,7 @@ void RiaSummaryCurveAnalyzer::appendAdresses( const std::vector<RifEclipseSummar
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveAnalyzer::appendAdresses( const std::set<RifEclipseSummaryAddress>& allAddresses )
void RiaSummaryCurveAnalyzer::appendAddresses( const std::set<RifEclipseSummaryAddress>& allAddresses )
{
for ( const auto& adr : allAddresses )
{

View File

@ -37,8 +37,8 @@ class RiaSummaryCurveAnalyzer
public:
RiaSummaryCurveAnalyzer();
void appendAdresses( const std::set<RifEclipseSummaryAddress>& allAddresses );
void appendAdresses( const std::vector<RifEclipseSummaryAddress>& allAddresses );
void appendAddresses( const std::set<RifEclipseSummaryAddress>& allAddresses );
void appendAddresses( const std::vector<RifEclipseSummaryAddress>& allAddresses );
void clear();

View File

@ -146,7 +146,7 @@ QString RicSummaryPlotTemplateTools::htmlTextFromPlotAndSelection(
RiaSummaryCurveAnalyzer selectionAnalyzer;
selectionAnalyzer.appendAdresses( selectedSummaryAddresses );
selectionAnalyzer.appendAddresses( selectedSummaryAddresses );
if ( templatePlot )
{
@ -169,7 +169,7 @@ QString RicSummaryPlotTemplateTools::htmlTextFromPlotAndSelection(
}
}
templateAnalyzer.appendAdresses( templateAddresses );
templateAnalyzer.appendAddresses( templateAddresses );
}
text += "<b> Requirements </b><br>";

View File

@ -127,7 +127,17 @@ void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered( bool isChecked )
CVF_ASSERT( !project->summaryGroups().empty() );
auto ensemble = project->summaryGroups().back();
RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetAndUpdate( ensemble );
auto curveSet = RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSet( plot, ensemble );
plot->loadDataAndUpdate();
plot->updateConnectedEditors();
RiaGuiApplication* app = RiaGuiApplication::instance();
RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow();
if ( mainPlotWindow )
{
mainPlotWindow->selectAsCurrentItem( curveSet );
mainPlotWindow->updateSummaryPlotToolBar();
}
}
}

View File

@ -394,7 +394,7 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurve::calculateValueOptions( const caf:
}
else if ( &m_yValuesSummaryAddressUiField == fieldNeedingOptions )
{
appendOptionItemsForSummaryAddresses( &options, m_yValuesSummaryCase());
appendOptionItemsForSummaryAddresses( &options, m_yValuesSummaryCase() );
}
else if ( &m_xValuesSummaryAddressUiField == fieldNeedingOptions )
{
@ -624,15 +624,6 @@ void RimSummaryCurve::defineEditorAttribute( const caf::PdmFieldHandle* field,
attrib->m_buttonText = "...";
}
}
if ( &m_yValuesSummaryAddressUiField == field || &m_xValuesSummaryAddressUiField == field )
{
auto* attrib = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute );
if ( attrib )
{
attrib->completerCaseSensitivity = Qt::CaseInsensitive;
}
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -47,7 +47,7 @@ void RimSummaryPlotNameHelper::clear()
//--------------------------------------------------------------------------------------------------
void RimSummaryPlotNameHelper::appendAddresses( const std::vector<RifEclipseSummaryAddress>& addresses )
{
m_analyzer.appendAdresses( addresses );
m_analyzer.appendAddresses( addresses );
extractPlotTitleSubStrings();
}

View File

@ -19,6 +19,7 @@
#include "RimSummaryPlotSourceStepping.h"
#include "RiaGuiApplication.h"
#include "RiaStdStringTools.h"
#include "RiaSummaryCurveAnalyzer.h"
#include "RiaSummaryCurveDefinition.h"
@ -37,7 +38,6 @@
#include "RiuPlotMainWindow.h"
#include "RiaStdStringTools.h"
#include "cafPdmUiComboBoxEditor.h"
#include "cafPdmUiItem.h"
#include "cafPdmUiListEditor.h"
@ -50,36 +50,33 @@ CAF_PDM_SOURCE_INIT( RimSummaryPlotSourceStepping, "RimSummaryCurveCollectionMod
RimSummaryPlotSourceStepping::RimSummaryPlotSourceStepping()
: m_sourceSteppingType( Y_AXIS )
{
// clang-format off
CAF_PDM_InitObject("Summary Curves Modifier", "", "", "");
CAF_PDM_InitObject( "Summary Curves Modifier", "", "", "" );
CAF_PDM_InitFieldNoDefault(&m_summaryCase, "CurveCase", "Case", "", "", "");
CAF_PDM_InitFieldNoDefault( &m_summaryCase, "CurveCase", "Case", "", "", "" );
CAF_PDM_InitField(&m_includeEnsembleCasesForCaseStepping,
"IncludeEnsembleCasesForCaseStepping",
false,
"Allow Stepping on Ensemble cases",
"",
"",
"");
CAF_PDM_InitField( &m_includeEnsembleCasesForCaseStepping,
"IncludeEnsembleCasesForCaseStepping",
false,
"Allow Stepping on Ensemble cases",
"",
"",
"" );
CAF_PDM_InitFieldNoDefault(&m_wellName, "WellName", "Well Name", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellGroupName, "GroupName", "Group Name", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_region, "Region", "Region", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_quantity, "Quantities", "Quantity", "", "", "");
CAF_PDM_InitFieldNoDefault( &m_wellName, "WellName", "Well Name", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_wellGroupName, "GroupName", "Group Name", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_region, "Region", "Region", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_quantity, "Quantities", "Quantity", "", "", "" );
CAF_PDM_InitFieldNoDefault(&m_cellBlock, "CellBlock", "Block", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_segment, "Segment", "Segment", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_completion, "Completion", "Completion", "", "", "");
CAF_PDM_InitFieldNoDefault( &m_cellBlock, "CellBlock", "Block", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_segment, "Segment", "Segment", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_completion, "Completion", "Completion", "", "", "" );
CAF_PDM_InitFieldNoDefault(&m_ensemble, "Ensemble", "Ensemble", "", "", "");
CAF_PDM_InitFieldNoDefault( &m_ensemble, "Ensemble", "Ensemble", "", "", "" );
CAF_PDM_InitFieldNoDefault(&m_placeholderForLabel, "Placeholder", "", "", "", "");
CAF_PDM_InitFieldNoDefault( &m_placeholderForLabel, "Placeholder", "", "", "", "" );
m_placeholderForLabel = "No common identifiers detected";
m_placeholderForLabel.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
m_placeholderForLabel.uiCapability()->setUiReadOnly(true);
// clang-format on
m_placeholderForLabel.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
m_placeholderForLabel.uiCapability()->setUiReadOnly( true );
}
//--------------------------------------------------------------------------------------------------
@ -164,7 +161,7 @@ std::vector<caf::PdmFieldHandle*> RimSummaryPlotSourceStepping::fieldsToShowInTo
void RimSummaryPlotSourceStepping::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
auto visible = computeVisibleFieldsAndSetFieldVisibility();
if ( visible.size() == 0 )
if ( visible.empty() )
{
m_placeholderForLabel.uiCapability()->setUiHidden( false );
}
@ -189,7 +186,7 @@ QList<caf::PdmOptionItemInfo>
}
else if ( fieldNeedingOptions == &m_placeholderForLabel )
{
options;
return options;
}
else if ( fieldNeedingOptions == &m_summaryCase )
{
@ -215,17 +212,17 @@ QList<caf::PdmOptionItemInfo>
return options;
}
std::vector<RifSummaryReaderInterface*> readers = summaryReadersForCurves();
if ( !readers.empty() )
auto addresses = adressesForSourceStepping();
if ( !addresses.empty() )
{
if ( fieldNeedingOptions == &m_quantity )
{
RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_FIELD;
auto addresses = addressesCurveCollection();
if ( !addresses.empty() )
auto visibleCurveAddresses = addressesForCurvesInPlot();
if ( !visibleCurveAddresses.empty() )
{
category = addresses.begin()->category();
category = visibleCurveAddresses.begin()->category();
}
std::map<QString, QString> displayAndValueStrings;
@ -233,20 +230,13 @@ QList<caf::PdmOptionItemInfo>
{
RiaSummaryCurveAnalyzer quantityAnalyzer;
for ( auto reader : readers )
{
if ( reader != nullptr )
{
auto subset = RiaSummaryCurveAnalyzer::addressesForCategory( reader->allResultAddresses(),
category );
quantityAnalyzer.appendAdresses( subset );
}
}
auto subset = RiaSummaryCurveAnalyzer::addressesForCategory( addresses, category );
quantityAnalyzer.appendAddresses( subset );
RiaSummaryCurveAnalyzer analyzerForCurves;
analyzerForCurves.appendAdresses( addressesCurveCollection() );
RiaSummaryCurveAnalyzer analyzerForVisibleCurves;
analyzerForVisibleCurves.appendAddresses( visibleCurveAddresses );
if ( analyzerForCurves.quantityNamesWithHistory().empty() )
if ( analyzerForVisibleCurves.quantityNamesWithHistory().empty() )
{
auto quantities = quantityAnalyzer.quantities();
for ( const auto& s : quantities )
@ -258,6 +248,9 @@ QList<caf::PdmOptionItemInfo>
}
else
{
// The plot displays a mix of simulated and observed vectors
// Create a combined item for source stepping
auto quantitiesWithHistory = quantityAnalyzer.quantityNamesWithHistory();
for ( const auto& s : quantitiesWithHistory )
{
@ -323,15 +316,10 @@ QList<caf::PdmOptionItemInfo>
if ( category != RifEclipseSummaryAddress::SUMMARY_INVALID )
{
for ( auto reader : readers )
{
auto analyzer = analyzerForReader( reader );
RiaSummaryCurveAnalyzer analyzer;
analyzer.appendAddresses( addresses );
if ( analyzer )
{
identifierTexts = analyzer->identifierTexts( category, secondaryIdentifier );
}
}
identifierTexts = analyzer.identifierTexts( category, secondaryIdentifier );
}
if ( !identifierTexts.empty() )
@ -558,8 +546,8 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle*
RimSummaryCrossPlot* summaryCrossPlot = dynamic_cast<RimSummaryCrossPlot*>( summaryPlot );
if ( summaryCrossPlot )
{
// Trigger update of curve collection (and summary toolbar in main window), as the visibility of combo boxes
// might have been changed due to the updates in this function
// Trigger update of curve collection (and summary toolbar in main window), as the visibility of combo
// boxes might have been changed due to the updates in this function
if ( curveCollection )
{
curveCollection->updateConnectedEditors();
@ -571,58 +559,13 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle*
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RifSummaryReaderInterface*> RimSummaryPlotSourceStepping::summaryReadersForCurves() const
{
std::vector<RifSummaryReaderInterface*> readers;
RimSummaryCurveCollection* curveCollection = nullptr;
this->firstAncestorOrThisOfType( curveCollection );
if ( curveCollection )
{
for ( auto curve : curveCollection->curves() )
{
if ( isYAxisStepping() && curve->summaryCaseY() && curve->summaryCaseY()->summaryReader() )
{
readers.push_back( curve->summaryCaseY()->summaryReader() );
}
if ( isXAxisStepping() && curve->summaryCaseX() && curve->summaryCaseX()->summaryReader() )
{
readers.push_back( curve->summaryCaseX()->summaryReader() );
}
}
}
RimEnsembleCurveSetCollection* ensembleCollection = nullptr;
this->firstAncestorOrThisOfType( ensembleCollection );
if ( ensembleCollection )
{
auto curveSets = ensembleCollection->curveSets();
for ( const RimEnsembleCurveSet* curveSet : curveSets )
{
for ( auto curve : curveSet->curves() )
{
if ( isYAxisStepping() && curve->summaryCaseY() && curve->summaryCaseY()->summaryReader() )
{
readers.push_back( curve->summaryCaseY()->summaryReader() );
}
}
}
}
return readers;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmValueField* RimSummaryPlotSourceStepping::fieldToModify()
{
RiaSummaryCurveAnalyzer analyzer;
analyzer.appendAdresses( addressesCurveCollection() );
analyzer.appendAddresses( addressesForCurvesInPlot() );
if ( analyzer.wellNames().size() == 1 )
{
@ -660,7 +603,49 @@ caf::PdmValueField* RimSummaryPlotSourceStepping::fieldToModify()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RifEclipseSummaryAddress> RimSummaryPlotSourceStepping::addressesCurveCollection() const
std::set<RifEclipseSummaryAddress> RimSummaryPlotSourceStepping::adressesForSourceStepping() const
{
std::set<RifEclipseSummaryAddress> addressSet;
RimEnsembleCurveSetCollection* ensembleCollection = nullptr;
this->firstAncestorOrThisOfType( ensembleCollection );
if ( ensembleCollection )
{
auto curveSets = ensembleCollection->curveSetsForSourceStepping();
for ( const RimEnsembleCurveSet* curveSet : curveSets )
{
auto addresses = curveSet->summaryCaseCollection()->ensembleSummaryAddresses();
addressSet.insert( addresses.begin(), addresses.end() );
}
}
RimSummaryCurveCollection* curveCollection = nullptr;
this->firstAncestorOrThisOfType( curveCollection );
if ( curveCollection )
{
for ( auto curve : curveCollection->curvesForSourceStepping( m_sourceSteppingType ) )
{
if ( isYAxisStepping() && curve->summaryCaseY() && curve->summaryCaseY()->summaryReader() )
{
auto addresses = curve->summaryCaseY()->summaryReader()->allResultAddresses();
addressSet.insert( addresses.begin(), addresses.end() );
}
if ( isXAxisStepping() && curve->summaryCaseX() && curve->summaryCaseX()->summaryReader() )
{
auto addresses = curve->summaryCaseX()->summaryReader()->allResultAddresses();
addressSet.insert( addresses.begin(), addresses.end() );
}
}
}
return addressSet;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RifEclipseSummaryAddress> RimSummaryPlotSourceStepping::addressesForCurvesInPlot() const
{
std::set<RifEclipseSummaryAddress> addresses;
@ -781,7 +766,7 @@ std::vector<caf::PdmFieldHandle*> RimSummaryPlotSourceStepping::computeVisibleFi
{
RiaSummaryCurveAnalyzer analyzer;
analyzer.appendAdresses( addressesCurveCollection() );
analyzer.appendAddresses( addressesForCurvesInPlot() );
RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_INVALID;
@ -942,7 +927,7 @@ RiaSummaryCurveAnalyzer* RimSummaryPlotSourceStepping::analyzerForReader( RifSum
m_curveAnalyzerForReader = std::make_pair( reader, analyzer );
}
m_curveAnalyzerForReader.second.appendAdresses( reader->allResultAddresses() );
m_curveAnalyzerForReader.second.appendAddresses( reader->allResultAddresses() );
return &m_curveAnalyzerForReader.second;
}

View File

@ -81,10 +81,11 @@ private:
caf::PdmUiEditorAttribute* attribute ) override;
private:
std::vector<RifSummaryReaderInterface*> summaryReadersForCurves() const;
caf::PdmValueField* fieldToModify();
caf::PdmValueField* fieldToModify();
std::set<RifEclipseSummaryAddress> addressesCurveCollection() const;
std::set<RifEclipseSummaryAddress> adressesForSourceStepping() const;
std::set<RifEclipseSummaryAddress> addressesForCurvesInPlot() const;
std::set<RimSummaryCase*> summaryCasesCurveCollection() const;
std::vector<caf::PdmFieldHandle*> computeVisibleFieldsAndSetFieldVisibility();
std::set<RimSummaryCaseCollection*> ensembleCollection() const;

View File

@ -44,7 +44,7 @@ TEST( RiaSummaryCurveAnalyzer, WellCompletions )
}
RiaSummaryCurveAnalyzer analyzer;
analyzer.appendAdresses( addresses );
analyzer.appendAddresses( addresses );
EXPECT_EQ( 2u, analyzer.wellNames().size() );
@ -95,7 +95,7 @@ TEST( RiaSummaryCurveAnalyzer, WellSegments )
}
RiaSummaryCurveAnalyzer analyzer;
analyzer.appendAdresses( addresses );
analyzer.appendAddresses( addresses );
EXPECT_EQ( 2u, analyzer.wellNames().size() );
@ -131,7 +131,7 @@ TEST( RiaSummaryCurveAnalyzer, CellBlocks )
}
RiaSummaryCurveAnalyzer analyzer;
analyzer.appendAdresses( addresses );
analyzer.appendAddresses( addresses );
auto blocks = analyzer.blocks();
EXPECT_EQ( 3u, blocks.size() );

View File

@ -574,6 +574,12 @@ void RiuPlotMainWindow::updateSummaryPlotToolBar( bool forceUpdateUi )
else
{
toolBarFields = summaryPlot->summaryCurveCollection()->fieldsToShowInToolbar();
if ( toolBarFields.empty() )
{
// Show ensemble stepping if no fields are available from summary stepping
toolBarFields = summaryPlot->ensembleCurveSetCollection()->fieldsToShowInToolbar();
}
}
if ( !m_summaryPlotToolBarEditor->isEditorDataValid( toolBarFields ) )

View File

@ -62,7 +62,7 @@ public:
PdmUiLineEditorAttribute()
{
avoidSendingEnterEventToParentWidget = false;
completerCaseSensitivity = Qt::CaseSensitive;
completerCaseSensitivity = Qt::CaseInsensitive;
completerFilterMode = Qt::MatchContains;
}