Skip to content

Commit

Permalink
#11147: Initialize well allocation plot with better data
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
magnesj committed Feb 1, 2024
1 parent 75abb1e commit 1b15886
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 26 deletions.
8 changes: 8 additions & 0 deletions ApplicationLibCode/Application/RiaPlotDefines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ QString RiaDefines::namingVariableWaterDepth()
return "$WATER_DEPTH";
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaDefines::selectionTextNone()
{
return "None";
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions ApplicationLibCode/Application/RiaPlotDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ QString namingVariableTimestep();
QString namingVariableAirGap();
QString namingVariableWaterDepth();

QString selectionTextNone();

double minimumDefaultValuePlot();
double minimumDefaultLogValuePlot();
double maximumDefaultValuePlot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ int RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( const QStr
return -1;
}

RimMainPlotCollection::current()->ensureDefaultFlowPlotsAreCreated();

if ( createView )
{
RimEclipseView* riv = rimResultReservoir->createAndAddReservoirView();
Expand Down
99 changes: 73 additions & 26 deletions ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" );
Expand Down Expand Up @@ -219,6 +221,57 @@ void RimWellAllocationPlot::deleteViewWidget()
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::setCase( RimEclipseResultCase* eclipseCase )
{
bool emptyPreviousCase = !m_case;

m_case = eclipseCase;

if ( m_case )
{
m_flowDiagSolution = m_case->defaultFlowDiagSolution();
}
else
{
m_flowDiagSolution = nullptr;
m_timeStep = 0;
}

if ( !m_case )
m_timeStep = 0;
else
{
if ( emptyPreviousCase )
{
m_timeStep = (int)( m_case->timeStepDates().size() - 1 );
}

m_timeStep = std::min( m_timeStep(), ( (int)m_case->timeStepDates().size() ) - 1 );
}

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();
}
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -732,36 +785,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 ||
Expand Down Expand Up @@ -849,7 +892,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() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class RimWellAllocationPlot : public RimViewWindow
void onLoadDataAndUpdate() override;

private:
void setCase( RimEclipseResultCase* eclipseCase);
void updateFromWell();
void updateWellFlowPlotXAxisTitle( RimWellLogTrack* plotTrack );

Expand Down
3 changes: 3 additions & 0 deletions ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down

0 comments on commit 1b15886

Please sign in to comment.