#11147: Initialize well allocation plot with better data

If plot is empty, initialize well allocation plot with case, first producer and last available time step
Make sure that all flow diagnostics plots are visible at all times.
This commit is contained in:
Magne Sjaastad 2024-02-02 10:20:05 +01:00
parent e2e441c1a0
commit 4dd43a14a0
6 changed files with 84 additions and 26 deletions

View File

@ -169,6 +169,14 @@ QString RiaDefines::namingVariableWaterDepth()
return "$WATER_DEPTH";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaDefines::selectionTextNone()
{
return "None";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -93,6 +93,8 @@ QString namingVariableTimestep();
QString namingVariableAirGap();
QString namingVariableWaterDepth();
QString selectionTextNone();
double minimumDefaultValuePlot();
double minimumDefaultLogValuePlot();
double maximumDefaultValuePlot();

View File

@ -358,6 +358,8 @@ int RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( const QStr
return -1;
}
RimMainPlotCollection::current()->ensureDefaultFlowPlotsAreCreated();
if ( createView )
{
RimEclipseView* riv = rimResultReservoir->createAndAddReservoirView();

View File

@ -19,10 +19,12 @@
#include "RimWellAllocationPlot.h"
#include "RiaNumericalTools.h"
#include "RiaPlotDefines.h"
#include "RiaPreferences.h"
#include "RigAccWellFlowCalculator.h"
#include "RigEclipseCaseData.h"
#include "RigEclipseCaseDataTools.h"
#include "RigFlowDiagResultAddress.h"
#include "RigFlowDiagResults.h"
#include "RigSimWellData.h"
@ -95,7 +97,7 @@ RimWellAllocationPlot::RimWellAllocationPlot()
m_case.uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitField( &m_timeStep, "PlotTimeStep", 0, "Time Step" );
CAF_PDM_InitField( &m_wellName, "WellName", QString( "None" ), "Well" );
CAF_PDM_InitField( &m_wellName, "WellName", RiaDefines::selectionTextNone(), "Well" );
CAF_PDM_InitFieldNoDefault( &m_flowDiagSolution, "FlowDiagSolution", "Plot Type" );
CAF_PDM_InitFieldNoDefault( &m_flowType, "FlowType", "Flow Type" );
CAF_PDM_InitField( &m_groupSmallContributions, "GroupSmallContributions", true, "Group Small Contributions" );
@ -219,6 +221,52 @@ void RimWellAllocationPlot::deleteViewWidget()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::setCase( RimEclipseResultCase* eclipseCase )
{
bool emptyPreviousCase = !m_case;
m_case = eclipseCase;
if ( m_case )
{
m_flowDiagSolution = m_case->defaultFlowDiagSolution();
if ( emptyPreviousCase )
{
m_timeStep = (int)( m_case->timeStepDates().size() - 1 );
}
m_timeStep = std::min( m_timeStep(), ( (int)m_case->timeStepDates().size() ) - 1 );
}
else
{
m_flowDiagSolution = nullptr;
m_timeStep = 0;
}
if ( m_wellName().isEmpty() || m_wellName() == RiaDefines::selectionTextNone() )
{
auto firstProducer = RigEclipseCaseDataTools::firstProducer( m_case->eclipseCaseData() );
if ( !firstProducer.isEmpty() )
{
m_wellName = firstProducer;
}
else
{
std::set<QString> sortedWellNames = findSortedWellNames();
if ( sortedWellNames.empty() )
m_wellName = RiaDefines::selectionTextNone();
else if ( sortedWellNames.count( m_wellName() ) == 0 )
{
m_wellName = *sortedWellNames.begin();
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -732,36 +780,26 @@ void RimWellAllocationPlot::fieldChangedByUi( const caf::PdmFieldHandle* changed
{
RimViewWindow::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_showWindow )
{
if ( !m_case )
{
auto resultCases = RimEclipseCaseTools::eclipseResultCases();
if ( !resultCases.empty() )
{
setCase( resultCases.front() );
onLoadDataAndUpdate();
}
}
}
if ( changedField == &m_userName || changedField == &m_showPlotTitle )
{
updateWidgetTitleWindowTitle();
}
else if ( changedField == &m_case )
{
if ( m_flowDiagSolution && m_case )
{
m_flowDiagSolution = m_case->defaultFlowDiagSolution();
}
else
{
m_flowDiagSolution = nullptr;
}
if ( !m_case )
m_timeStep = 0;
else if ( m_timeStep >= static_cast<int>( m_case->timeStepDates().size() ) )
{
m_timeStep = std::max( 0, ( (int)m_case->timeStepDates().size() ) - 1 );
}
std::set<QString> sortedWellNames = findSortedWellNames();
if ( sortedWellNames.empty() )
m_wellName = "";
else if ( sortedWellNames.count( m_wellName() ) == 0 )
{
m_wellName = *sortedWellNames.begin();
}
setCase( m_case );
onLoadDataAndUpdate();
}
else if ( changedField == &m_wellName || changedField == &m_timeStep || changedField == &m_flowDiagSolution ||
@ -849,7 +887,11 @@ void RimWellAllocationPlot::onLoadDataAndUpdate()
{
updateMdiWindowVisibility();
if ( !m_case ) return;
if ( !m_case )
{
m_flowDiagSolution = nullptr;
return;
}
// If no 3D view is open, we have to make sure the case is opened
if ( !m_case->ensureReservoirCaseIsOpen() )

View File

@ -109,6 +109,7 @@ protected:
void onLoadDataAndUpdate() override;
private:
void setCase( RimEclipseResultCase* eclipseCase);
void updateFromWell();
void updateWellFlowPlotXAxisTitle( RimWellLogTrack* plotTrack );

View File

@ -174,6 +174,9 @@ void RiuPlotMainWindow::initializeGuiNewProjectLoaded()
setPdmRoot( RimProject::current() );
restoreTreeViewState();
RimMainPlotCollection* mainPlotColl = RimMainPlotCollection::current();
mainPlotColl->ensureDefaultFlowPlotsAreCreated();
auto sumPlotManager = dynamic_cast<RimSummaryPlotManager*>( m_summaryPlotManager.get() );
if ( sumPlotManager )
{