2017-03-24 09:10:39 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-03-27 13:20:42 -05:00
|
|
|
//
|
2017-03-24 09:10:39 -05:00
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2019-03-27 13:20:42 -05:00
|
|
|
//
|
2017-03-24 09:10:39 -05:00
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
2019-03-27 13:20:42 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-03-24 09:10:39 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RimFlowCharacteristicsPlot.h"
|
|
|
|
|
2019-06-23 11:32:05 -05:00
|
|
|
#include "RiaPreferences.h"
|
|
|
|
|
|
|
|
#include "RifCsvDataTableFormatter.h"
|
2019-06-23 08:18:17 -05:00
|
|
|
|
2017-08-24 02:27:08 -05:00
|
|
|
#include "RigActiveCellInfo.h"
|
2019-03-27 13:20:42 -05:00
|
|
|
#include "RigEclipseCaseData.h"
|
|
|
|
#include "RigFlowDiagResults.h"
|
2017-03-24 09:10:39 -05:00
|
|
|
|
2017-08-17 04:24:51 -05:00
|
|
|
#include "RimEclipseCellColors.h"
|
2017-08-17 06:49:51 -05:00
|
|
|
#include "RimEclipsePropertyFilter.h"
|
|
|
|
#include "RimEclipsePropertyFilterCollection.h"
|
2019-03-27 13:20:42 -05:00
|
|
|
#include "RimEclipseResultCase.h"
|
|
|
|
#include "RimEclipseView.h"
|
2017-10-15 14:20:03 -05:00
|
|
|
#include "RimFaultInViewCollection.h"
|
2019-03-27 13:20:42 -05:00
|
|
|
#include "RimFlowDiagSolution.h"
|
|
|
|
#include "RimProject.h"
|
2017-08-17 04:24:51 -05:00
|
|
|
|
|
|
|
#include "RicEclipsePropertyFilterFeatureImpl.h"
|
2017-08-17 06:49:51 -05:00
|
|
|
#include "RicSelectOrCreateViewFeatureImpl.h"
|
2017-03-24 09:10:39 -05:00
|
|
|
|
2017-03-28 02:47:06 -05:00
|
|
|
#include "RiuFlowCharacteristicsPlot.h"
|
2017-08-17 04:24:51 -05:00
|
|
|
#include "RiuMainWindow.h"
|
2017-03-28 02:47:06 -05:00
|
|
|
|
2017-05-11 14:44:44 -05:00
|
|
|
#include "cafPdmUiCheckBoxEditor.h"
|
2017-08-17 04:24:51 -05:00
|
|
|
#include "cafPdmUiListEditor.h"
|
|
|
|
#include "cafPdmUiPushButtonEditor.h"
|
|
|
|
#include "cafUtils.h"
|
2017-05-11 14:44:44 -05:00
|
|
|
|
2017-08-11 03:24:35 -05:00
|
|
|
#include <QDateTime>
|
|
|
|
|
2017-03-28 02:47:06 -05:00
|
|
|
#include <cmath> // Needed for HUGE_VAL on Linux
|
|
|
|
|
2017-03-29 02:28:14 -05:00
|
|
|
namespace caf
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
template <>
|
2019-03-27 13:20:42 -05:00
|
|
|
void AppEnum<RimFlowCharacteristicsPlot::TimeSelectionType>::setUp()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
addItem( RimFlowCharacteristicsPlot::ALL_AVAILABLE, "ALL_AVAILABLE", "All With Calculated Flow Diagnostics" );
|
|
|
|
addItem( RimFlowCharacteristicsPlot::SELECTED, "SELECTED", "Selected" );
|
|
|
|
setDefault( RimFlowCharacteristicsPlot::SELECTED );
|
2017-03-29 02:28:14 -05:00
|
|
|
}
|
2019-03-27 13:20:42 -05:00
|
|
|
} // namespace caf
|
2017-03-29 02:28:14 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RimFlowCharacteristicsPlot, "FlowCharacteristicsPlot" );
|
2017-03-24 09:10:39 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimFlowCharacteristicsPlot::RimFlowCharacteristicsPlot()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_InitObject( "Flow Characteristics", ":/FlowCharPlot16x16.png", "", "" );
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_case, "FlowCase", "Case", "", "", "" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_flowDiagSolution, "FlowDiagSolution", "Flow Diag Solution", "", "", "" );
|
|
|
|
m_flowDiagSolution.uiCapability()->setUiHidden( true );
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_timeStepSelectionType, "TimeSelectionType", "Time Steps", "", "", "" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_selectedTimeSteps, "SelectedTimeSteps", "", "", "", "" );
|
|
|
|
m_selectedTimeSteps.uiCapability()->setUiHidden( true );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_selectedTimeStepsUi, "SelectedTimeStepsUi", "", "", "", "" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_applyTimeSteps, "ApplyTimeSteps", "", "", "", "" );
|
|
|
|
caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyTimeSteps );
|
|
|
|
|
|
|
|
CAF_PDM_InitField( &m_maxPvFraction,
|
|
|
|
"CellPVThreshold",
|
|
|
|
0.1,
|
|
|
|
"Aquifer Cell Threshold",
|
|
|
|
"",
|
|
|
|
"Exclude Aquifer Effects by adding a Cell Pore Volume Threshold as Fraction of Total Pore "
|
|
|
|
"Volume.",
|
|
|
|
"" );
|
|
|
|
|
|
|
|
CAF_PDM_InitField( &m_showLegend, "ShowLegend", true, "Legend", "", "", "" );
|
2017-05-11 14:44:44 -05:00
|
|
|
|
2017-08-17 04:24:51 -05:00
|
|
|
// Region group
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_cellFilter, "CellFilter", "Cell Filter", "", "", "" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_cellFilterView, "CellFilterView", "View", "", "", "" );
|
|
|
|
CAF_PDM_InitField( &m_tracerFilter, "TracerFilter", QString(), "Tracer Filter", "", "", "" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_selectedTracerNames, "SelectedTracerNames", " ", "", "", "" );
|
|
|
|
m_selectedTracerNames.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_showRegion, "ShowRegion", "", "", "", "" );
|
|
|
|
caf::PdmUiPushButtonEditor::configureEditorForField( &m_showRegion );
|
2017-11-16 05:43:05 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_InitField( &m_minCommunication, "MinCommunication", 0.0, "Min Communication", "", "", "" );
|
|
|
|
CAF_PDM_InitField( &m_maxTof, "MaxTof", 146000, "Max Time of Flight [days]", "", "", "" );
|
2017-08-17 04:24:51 -05:00
|
|
|
|
2017-03-24 09:10:39 -05:00
|
|
|
this->m_showWindow = false;
|
|
|
|
setAsPlotMdiWindow();
|
2020-05-18 09:02:27 -05:00
|
|
|
setDeletable( true );
|
2017-03-24 09:10:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimFlowCharacteristicsPlot::~RimFlowCharacteristicsPlot()
|
|
|
|
{
|
|
|
|
removeMdiWindowFromMdiArea();
|
2019-03-27 13:20:42 -05:00
|
|
|
|
2019-11-07 01:48:11 -06:00
|
|
|
if ( m_flowCharPlotWidget )
|
|
|
|
{
|
2019-12-04 02:13:54 -06:00
|
|
|
m_flowCharPlotWidget->hide();
|
|
|
|
m_flowCharPlotWidget->setParent( nullptr );
|
|
|
|
delete m_flowCharPlotWidget;
|
2019-11-07 01:48:11 -06:00
|
|
|
m_flowCharPlotWidget = nullptr;
|
|
|
|
}
|
2017-03-24 09:10:39 -05:00
|
|
|
}
|
|
|
|
|
2019-11-14 13:48:11 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// TODO: implement properly
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
int RimFlowCharacteristicsPlot::id() const
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimFlowCharacteristicsPlot::setFromFlowSolution( RimFlowDiagSolution* flowSolution )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !flowSolution )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
2019-03-27 13:20:42 -05:00
|
|
|
m_case = nullptr;
|
2017-08-24 02:27:08 -05:00
|
|
|
m_cellFilterView = nullptr;
|
2017-03-24 09:10:39 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RimEclipseResultCase* eclCase;
|
2019-09-06 03:40:57 -05:00
|
|
|
flowSolution->firstAncestorOrThisOfType( eclCase );
|
2017-03-24 09:10:39 -05:00
|
|
|
m_case = eclCase;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !eclCase->reservoirViews.empty() )
|
2017-08-24 02:27:08 -05:00
|
|
|
{
|
|
|
|
m_cellFilterView = eclCase->reservoirViews()[0];
|
|
|
|
}
|
2017-03-24 09:10:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
m_flowDiagSolution = flowSolution;
|
2019-03-27 13:20:42 -05:00
|
|
|
m_showWindow = true;
|
2019-06-25 10:49:38 -05:00
|
|
|
m_timeStepToFlowResultMap.clear();
|
|
|
|
m_currentlyPlottedTimeSteps.clear();
|
2017-03-24 09:10:39 -05:00
|
|
|
|
2017-10-31 06:49:14 -05:00
|
|
|
onLoadDataAndUpdate();
|
2017-03-24 09:10:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimFlowCharacteristicsPlot::deleteViewWidget()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_flowCharPlotWidget )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
2019-12-04 02:13:54 -06:00
|
|
|
m_flowCharPlotWidget->hide();
|
|
|
|
m_flowCharPlotWidget->setParent( nullptr );
|
|
|
|
delete m_flowCharPlotWidget;
|
2019-03-27 13:20:42 -05:00
|
|
|
m_flowCharPlotWidget = nullptr;
|
2017-03-24 09:10:39 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-29 07:02:32 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-29 07:02:32 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimFlowCharacteristicsPlot::updateCurrentTimeStep()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_timeStepSelectionType() != ALL_AVAILABLE ) return;
|
|
|
|
if ( !m_flowDiagSolution() ) return;
|
2017-03-29 07:02:32 -05:00
|
|
|
|
2019-03-27 13:20:42 -05:00
|
|
|
RigFlowDiagResults* flowResult = m_flowDiagSolution->flowDiagResults();
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<int> calculatedTimesteps = flowResult->calculatedTimeSteps( RigFlowDiagResultAddress::PHASE_ALL );
|
2019-03-27 13:20:42 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_currentlyPlottedTimeSteps == calculatedTimesteps ) return;
|
2017-03-29 07:02:32 -05:00
|
|
|
|
2017-10-31 06:49:14 -05:00
|
|
|
this->onLoadDataAndUpdate();
|
2017-03-29 07:02:32 -05:00
|
|
|
}
|
|
|
|
|
2019-06-25 10:49:38 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimFlowCharacteristicsPlot::setTimeSteps( const std::vector<int>& timeSteps )
|
2019-06-25 10:49:38 -05:00
|
|
|
{
|
|
|
|
m_selectedTimeSteps = timeSteps;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimFlowCharacteristicsPlot::setInjectorsAndProducers( const std::vector<QString>& injectors,
|
|
|
|
const std::vector<QString>& producers )
|
2019-06-25 10:49:38 -05:00
|
|
|
{
|
|
|
|
std::vector<QString> allTracers;
|
|
|
|
|
|
|
|
allTracers = producers;
|
2019-09-06 03:40:57 -05:00
|
|
|
allTracers.insert( allTracers.end(), injectors.begin(), injectors.end() );
|
2019-06-25 10:49:38 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( producers.empty() && !injectors.empty() )
|
2019-06-25 10:49:38 -05:00
|
|
|
{
|
|
|
|
m_cellFilter = RigFlowDiagResults::CELLS_FLOODED;
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( !producers.empty() && injectors.empty() )
|
2019-06-25 10:49:38 -05:00
|
|
|
{
|
|
|
|
m_cellFilter = RigFlowDiagResults::CELLS_DRAINED;
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( !producers.empty() && !injectors.empty() )
|
2019-06-25 10:49:38 -05:00
|
|
|
{
|
|
|
|
m_cellFilter = RigFlowDiagResults::CELLS_COMMUNICATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_selectedTracerNames = allTracers;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimFlowCharacteristicsPlot::setMinimumCommunication( double minimumCommunication )
|
2019-06-25 10:49:38 -05:00
|
|
|
{
|
|
|
|
m_minCommunication = minimumCommunication;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimFlowCharacteristicsPlot::setAquiferCellThreshold( double aquiferCellThreshold )
|
2019-06-25 10:49:38 -05:00
|
|
|
{
|
|
|
|
m_maxPvFraction = aquiferCellThreshold;
|
|
|
|
}
|
|
|
|
|
2020-05-09 04:23:58 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
int RimFlowCharacteristicsPlot::fontSize() const
|
|
|
|
{
|
2020-06-08 04:09:11 -05:00
|
|
|
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize() );
|
2020-05-09 04:23:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimFlowCharacteristicsPlot::updateFonts()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
QList<caf::PdmOptionItemInfo>
|
2020-02-12 04:43:15 -06:00
|
|
|
RimFlowCharacteristicsPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( fieldNeedingOptions == &m_case )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
|
|
|
RimProject* proj = nullptr;
|
2019-09-06 03:40:57 -05:00
|
|
|
this->firstAncestorOrThisOfType( proj );
|
|
|
|
if ( proj )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
|
|
|
std::vector<RimEclipseResultCase*> cases;
|
2019-09-06 03:40:57 -05:00
|
|
|
proj->descendantsIncludingThisOfType( cases );
|
|
|
|
for ( RimEclipseResultCase* c : cases )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( c->defaultFlowDiagSolution() )
|
2017-04-06 04:12:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
options.push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, false, c->uiIconProvider() ) );
|
2017-04-06 04:12:51 -05:00
|
|
|
}
|
2017-03-24 09:10:39 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( fieldNeedingOptions == &m_cellFilterView )
|
2017-08-24 02:27:08 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_case )
|
2017-08-24 02:27:08 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimEclipseView* view : m_case()->reservoirViews() )
|
2017-08-24 02:27:08 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
options.push_back( caf::PdmOptionItemInfo( view->name(), view, false, view->uiIconProvider() ) );
|
2017-08-24 02:27:08 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( fieldNeedingOptions == &m_flowDiagSolution )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_case )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
|
|
|
std::vector<RimFlowDiagSolution*> flowSols = m_case->flowDiagSolutions();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) );
|
|
|
|
for ( RimFlowDiagSolution* flowSol : flowSols )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
options.push_back(
|
|
|
|
caf::PdmOptionItemInfo( flowSol->userDescription(), flowSol, false, flowSol->uiIconProvider() ) );
|
2017-03-24 09:10:39 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( fieldNeedingOptions == &m_selectedTimeStepsUi )
|
2017-03-29 02:28:14 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_flowDiagSolution && m_case )
|
2017-03-29 02:28:14 -05:00
|
|
|
{
|
2020-02-12 04:43:15 -06:00
|
|
|
QStringList timeStepDates = m_case->timeStepStrings();
|
|
|
|
std::vector<int> calculatedTimeSteps =
|
|
|
|
m_flowDiagSolution()->flowDiagResults()->calculatedTimeSteps( RigFlowDiagResultAddress::PHASE_ALL );
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( int tsIdx = 0; tsIdx < timeStepDates.size(); ++tsIdx )
|
2017-03-29 02:28:14 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto it = std::find( calculatedTimeSteps.begin(), calculatedTimeSteps.end(), tsIdx );
|
2017-08-17 04:24:51 -05:00
|
|
|
QString itemText = timeStepDates[tsIdx];
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( it != calculatedTimeSteps.end() )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
|
|
|
itemText = itemText + " *";
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
options.push_back( caf::PdmOptionItemInfo( itemText, tsIdx ) );
|
2017-08-17 04:24:51 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( fieldNeedingOptions == &m_selectedTracerNames )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_flowDiagSolution )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-03-27 13:20:42 -05:00
|
|
|
std::vector<QString> tracerNames = m_flowDiagSolution->tracerNames();
|
2017-08-21 06:37:35 -05:00
|
|
|
std::vector<std::pair<QString, QString>> sortedTracerNames;
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( QString tracerName : tracerNames )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !caf::Utils::isStringMatch( m_tracerFilter, tracerName ) ) continue;
|
2017-08-17 04:24:51 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RimFlowDiagSolution::TracerStatusType tracerStatus = m_flowDiagSolution->tracerStatusOverall( tracerName );
|
|
|
|
if ( tracerStatus == RimFlowDiagSolution::CLOSED ) continue;
|
2017-08-17 04:24:51 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_cellFilter() == RigFlowDiagResults::CELLS_FLOODED )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( tracerStatus == RimFlowDiagSolution::INJECTOR || tracerStatus == RimFlowDiagSolution::VARYING )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
sortedTracerNames.push_back( std::make_pair( tracerName, tracerName ) );
|
2017-08-17 04:24:51 -05:00
|
|
|
}
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( m_cellFilter() == RigFlowDiagResults::CELLS_DRAINED )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( tracerStatus == RimFlowDiagSolution::PRODUCER || tracerStatus == RimFlowDiagSolution::VARYING )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
sortedTracerNames.push_back( std::make_pair( tracerName, tracerName ) );
|
2017-08-17 04:24:51 -05:00
|
|
|
}
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( m_cellFilter() == RigFlowDiagResults::CELLS_COMMUNICATION )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
|
|
|
QString prefix;
|
2019-09-06 03:40:57 -05:00
|
|
|
switch ( tracerStatus )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-03-27 13:20:42 -05:00
|
|
|
case RimFlowDiagSolution::INJECTOR:
|
|
|
|
prefix = "I : ";
|
|
|
|
break;
|
|
|
|
case RimFlowDiagSolution::PRODUCER:
|
|
|
|
prefix = "P : ";
|
|
|
|
break;
|
|
|
|
case RimFlowDiagSolution::VARYING:
|
|
|
|
prefix = "I/P: ";
|
|
|
|
break;
|
|
|
|
case RimFlowDiagSolution::UNDEFINED:
|
|
|
|
prefix = "U : ";
|
|
|
|
break;
|
2017-08-17 04:24:51 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
sortedTracerNames.push_back( std::make_pair( prefix + tracerName, tracerName ) );
|
2017-08-17 04:24:51 -05:00
|
|
|
}
|
2017-03-29 02:28:14 -05:00
|
|
|
}
|
2017-08-21 06:37:35 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
std::sort( sortedTracerNames.begin(),
|
|
|
|
sortedTracerNames.end(),
|
|
|
|
[]( const std::pair<QString, QString>& a, const std::pair<QString, QString>& b ) -> bool {
|
|
|
|
return a.first < b.first;
|
|
|
|
} );
|
2017-08-21 06:37:35 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto& tracer : sortedTracerNames )
|
2017-08-21 06:37:35 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
options.push_back( caf::PdmOptionItemInfo( tracer.first, tracer.second ) );
|
2017-08-21 06:37:35 -05:00
|
|
|
}
|
2017-03-29 02:28:14 -05:00
|
|
|
}
|
|
|
|
}
|
2017-03-24 09:10:39 -05:00
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
2017-03-29 02:28:14 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-29 02:28:14 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimFlowCharacteristicsPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
2017-03-29 02:28:14 -05:00
|
|
|
{
|
2017-08-22 04:45:06 -05:00
|
|
|
{
|
|
|
|
// Ensure a case is selected if one is available
|
|
|
|
RimProject* proj = nullptr;
|
2019-09-06 03:40:57 -05:00
|
|
|
this->firstAncestorOrThisOfType( proj );
|
|
|
|
if ( proj )
|
2017-08-22 04:45:06 -05:00
|
|
|
{
|
|
|
|
std::vector<RimEclipseResultCase*> cases;
|
2019-09-06 03:40:57 -05:00
|
|
|
proj->descendantsIncludingThisOfType( cases );
|
2017-08-22 04:45:06 -05:00
|
|
|
RimEclipseResultCase* defaultCase = nullptr;
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimEclipseResultCase* c : cases )
|
2017-08-22 04:45:06 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( c->defaultFlowDiagSolution() )
|
2017-08-22 04:45:06 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !defaultCase ) defaultCase = c; // Select first
|
2017-08-22 04:45:06 -05:00
|
|
|
}
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !m_case() && defaultCase )
|
2017-08-22 04:45:06 -05:00
|
|
|
{
|
2019-03-27 13:20:42 -05:00
|
|
|
m_case = defaultCase;
|
2017-08-22 04:45:06 -05:00
|
|
|
m_flowDiagSolution = m_case->defaultFlowDiagSolution();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !m_case()->reservoirViews.empty() )
|
2017-08-24 02:27:08 -05:00
|
|
|
{
|
|
|
|
m_cellFilterView = m_case()->reservoirViews()[0];
|
|
|
|
}
|
2017-08-22 04:45:06 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-05-11 14:44:44 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
uiOrdering.add( &m_case );
|
2017-08-22 04:46:44 -05:00
|
|
|
|
2017-08-21 04:29:34 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmUiGroup* timeStepsGroup = uiOrdering.addNewGroup( "Time Steps" );
|
2017-08-21 04:29:34 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
timeStepsGroup->add( &m_timeStepSelectionType );
|
2017-08-21 04:29:34 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_timeStepSelectionType == SELECTED )
|
2017-08-21 04:29:34 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
timeStepsGroup->add( &m_selectedTimeStepsUi );
|
|
|
|
timeStepsGroup->add( &m_applyTimeSteps );
|
2017-08-21 04:29:34 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmUiGroup* regionGroup = uiOrdering.addNewGroup( "Region" );
|
|
|
|
regionGroup->add( &m_cellFilter );
|
|
|
|
if ( m_cellFilter() == RigFlowDiagResults::CELLS_COMMUNICATION ||
|
|
|
|
m_cellFilter() == RigFlowDiagResults::CELLS_DRAINED || m_cellFilter() == RigFlowDiagResults::CELLS_FLOODED )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
regionGroup->add( &m_tracerFilter );
|
|
|
|
regionGroup->add( &m_selectedTracerNames );
|
|
|
|
regionGroup->add( &m_showRegion );
|
2017-08-17 04:24:51 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( m_cellFilter() == RigFlowDiagResults::CELLS_VISIBLE )
|
2017-08-24 02:27:08 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
regionGroup->add( &m_cellFilterView );
|
2017-08-24 02:27:08 -05:00
|
|
|
}
|
2017-08-29 09:21:19 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_cellFilter() == RigFlowDiagResults::CELLS_COMMUNICATION )
|
2017-08-29 09:21:19 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
regionGroup->add( &m_minCommunication );
|
2017-08-29 09:21:19 -05:00
|
|
|
}
|
2020-02-12 04:43:15 -06:00
|
|
|
else if ( m_cellFilter() == RigFlowDiagResults::CELLS_DRAINED || m_cellFilter() == RigFlowDiagResults::CELLS_FLOODED )
|
2017-08-29 09:21:19 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
regionGroup->add( &m_maxTof );
|
2017-08-29 09:21:19 -05:00
|
|
|
}
|
2017-08-17 04:24:51 -05:00
|
|
|
}
|
|
|
|
|
2017-08-21 04:51:34 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmUiGroup* optionsGroup = uiOrdering.addNewGroup( "Options" );
|
|
|
|
optionsGroup->add( &m_flowDiagSolution );
|
2017-08-21 04:51:34 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
optionsGroup->add( &m_showLegend );
|
|
|
|
optionsGroup->add( &m_maxPvFraction );
|
2017-08-21 04:51:34 -05:00
|
|
|
}
|
|
|
|
|
2017-03-29 02:28:14 -05:00
|
|
|
uiOrdering.skipRemainingFields();
|
|
|
|
}
|
|
|
|
|
2017-08-17 04:24:51 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-08-17 04:24:51 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimFlowCharacteristicsPlot::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
|
|
|
QString uiConfigName,
|
|
|
|
caf::PdmUiEditorAttribute* attribute )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( field == &m_applyTimeSteps )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
|
|
|
|
if ( attrib )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
|
|
|
attrib->m_buttonText = "Apply";
|
|
|
|
}
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( field == &m_showRegion )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
|
|
|
|
if ( attrib )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
|
|
|
attrib->m_buttonText = "Show Region";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QWidget* RimFlowCharacteristicsPlot::viewWidget()
|
|
|
|
{
|
|
|
|
return m_flowCharPlotWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimFlowCharacteristicsPlot::zoomAll()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_flowCharPlotWidget ) m_flowCharPlotWidget->zoomAll();
|
2017-03-24 09:10:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RimFlowCharacteristicsPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
|
|
|
const QVariant& oldValue,
|
|
|
|
const QVariant& newValue )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RimViewWindow::fieldChangedByUi( changedField, oldValue, newValue );
|
2017-03-24 09:10:39 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( &m_case == changedField )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
2017-08-24 02:27:08 -05:00
|
|
|
m_flowDiagSolution = m_case->defaultFlowDiagSolution();
|
|
|
|
m_currentlyPlottedTimeSteps.clear();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !m_case()->reservoirViews.empty() )
|
2017-08-24 02:27:08 -05:00
|
|
|
{
|
|
|
|
m_cellFilterView = m_case()->reservoirViews()[0];
|
|
|
|
}
|
2017-03-24 09:10:39 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( &m_applyTimeSteps == changedField )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_flowDiagSolution )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
|
|
|
// Compute any missing time steps from selected
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( int tsIdx : m_selectedTimeStepsUi() )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_flowDiagSolution()->flowDiagResults()->maxAbsPairFlux( tsIdx );
|
2017-08-17 04:24:51 -05:00
|
|
|
}
|
2017-08-21 06:09:06 -05:00
|
|
|
m_selectedTimeSteps = m_selectedTimeStepsUi;
|
2017-08-17 04:24:51 -05:00
|
|
|
}
|
|
|
|
m_applyTimeSteps = false;
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( &m_showRegion == changedField )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_case )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_cellFilter() != RigFlowDiagResults::CELLS_ACTIVE )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RimEclipseView* view =
|
|
|
|
RicSelectOrCreateViewFeatureImpl::showViewSelection( m_case,
|
|
|
|
"FlowCharacteristicsLastUsedView",
|
|
|
|
"RegionView",
|
|
|
|
"Show Region in View" );
|
2017-08-17 04:24:51 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( view != nullptr )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2017-08-24 02:53:27 -05:00
|
|
|
view->faultCollection()->showFaultCollection = false;
|
2020-04-23 16:25:22 -05:00
|
|
|
view->cellResult()->setResultType( RiaDefines::ResultCatType::FLOW_DIAGNOSTICS );
|
2019-09-06 03:40:57 -05:00
|
|
|
view->cellResult()->setFlowDiagTracerSelectionType( RimEclipseResultDefinition::FLOW_TR_BY_SELECTION );
|
|
|
|
view->cellResult()->setSelectedTracers( m_selectedTracerNames );
|
2017-08-22 04:47:36 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_cellFilter() == RigFlowDiagResults::CELLS_COMMUNICATION )
|
2017-08-22 04:47:36 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
view->cellResult()->setResultVariable( RIG_FLD_COMMUNICATION_RESNAME );
|
2017-08-22 04:47:36 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
view->cellResult()->setResultVariable( RIG_FLD_TOF_RESNAME );
|
2017-08-22 04:47:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int timeStep = 0;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_timeStepSelectionType() == ALL_AVAILABLE )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_flowDiagSolution )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<int> timeSteps = m_flowDiagSolution()->flowDiagResults()->calculatedTimeSteps(
|
|
|
|
RigFlowDiagResultAddress::PHASE_ALL );
|
|
|
|
if ( !timeSteps.empty() )
|
2017-08-22 04:47:36 -05:00
|
|
|
{
|
|
|
|
timeStep = timeSteps[0];
|
|
|
|
}
|
2017-08-17 04:24:51 -05:00
|
|
|
}
|
|
|
|
}
|
2017-08-22 04:47:36 -05:00
|
|
|
else
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !m_selectedTimeStepsUi().empty() )
|
2017-08-22 04:47:36 -05:00
|
|
|
{
|
|
|
|
timeStep = m_selectedTimeStepsUi()[0];
|
|
|
|
}
|
2017-08-17 04:24:51 -05:00
|
|
|
}
|
|
|
|
|
2017-08-22 04:47:36 -05:00
|
|
|
// Ensure selected time step has computed results
|
2019-09-06 03:40:57 -05:00
|
|
|
m_flowDiagSolution()->flowDiagResults()->maxAbsPairFlux( timeStep );
|
2017-08-17 04:24:51 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
view->setCurrentTimeStep( timeStep );
|
2017-08-17 06:49:51 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimEclipsePropertyFilter* f : view->eclipsePropertyFilterCollection()->propertyFilters() )
|
2017-08-22 04:47:36 -05:00
|
|
|
{
|
2021-01-11 11:47:09 -06:00
|
|
|
f->setActive( false );
|
2017-08-22 04:47:36 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
RicEclipsePropertyFilterFeatureImpl::addPropertyFilter( view->eclipsePropertyFilterCollection() );
|
2017-08-17 04:24:51 -05:00
|
|
|
|
2017-08-22 04:47:36 -05:00
|
|
|
view->loadDataAndUpdate();
|
|
|
|
m_case->updateConnectedEditors();
|
2017-08-17 04:24:51 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RicSelectOrCreateViewFeatureImpl::focusView( view );
|
2017-08-22 04:47:36 -05:00
|
|
|
}
|
2017-08-17 04:24:51 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( changedField == &m_cellFilter )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
|
|
|
m_selectedTracerNames = std::vector<QString>();
|
|
|
|
}
|
2017-03-24 09:10:39 -05:00
|
|
|
|
2017-03-29 02:28:14 -05:00
|
|
|
// All fields update plot
|
|
|
|
|
2017-10-31 06:49:14 -05:00
|
|
|
this->onLoadDataAndUpdate();
|
2017-03-24 09:10:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QImage RimFlowCharacteristicsPlot::snapshotWindowContent()
|
|
|
|
{
|
|
|
|
QImage image;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_flowCharPlotWidget )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
2019-09-13 08:13:49 -05:00
|
|
|
QPixmap pix = m_flowCharPlotWidget->grab();
|
2019-03-27 13:20:42 -05:00
|
|
|
image = pix.toImage();
|
2017-03-24 09:10:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-31 06:49:14 -05:00
|
|
|
void RimFlowCharacteristicsPlot::onLoadDataAndUpdate()
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
|
|
|
updateMdiWindowVisibility();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_flowDiagSolution && m_flowCharPlotWidget )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
2019-06-23 08:18:17 -05:00
|
|
|
RigFlowDiagResults* flowResult = m_flowDiagSolution->flowDiagResults();
|
2020-10-13 04:14:47 -05:00
|
|
|
if ( !flowResult ) return;
|
2019-03-27 13:20:42 -05:00
|
|
|
|
2017-03-29 02:28:14 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<int> calculatedTimesteps = flowResult->calculatedTimeSteps( RigFlowDiagResultAddress::PHASE_ALL );
|
2019-06-23 08:18:17 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_timeStepSelectionType == SELECTED )
|
2019-03-27 13:20:42 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( int tsIdx : m_selectedTimeSteps() )
|
2019-06-23 08:18:17 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_flowDiagSolution()->flowDiagResults()->maxAbsPairFlux( tsIdx );
|
2019-06-23 08:18:17 -05:00
|
|
|
}
|
|
|
|
calculatedTimesteps = m_selectedTimeSteps();
|
2017-03-29 02:28:14 -05:00
|
|
|
}
|
2019-03-27 13:20:42 -05:00
|
|
|
|
2019-06-23 08:18:17 -05:00
|
|
|
m_currentlyPlottedTimeSteps = calculatedTimesteps;
|
|
|
|
}
|
2017-03-29 02:28:14 -05:00
|
|
|
|
2019-03-27 13:20:42 -05:00
|
|
|
std::vector<QDateTime> timeStepDates = m_case->timeStepDates();
|
|
|
|
QStringList timeStepStrings = m_case->timeStepStrings();
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<double> lorenzVals( timeStepDates.size(), HUGE_VAL );
|
2017-03-24 09:10:39 -05:00
|
|
|
|
2017-03-28 16:35:53 -05:00
|
|
|
m_flowCharPlotWidget->removeAllCurves();
|
|
|
|
|
2017-08-17 04:24:51 -05:00
|
|
|
std::vector<QString> selectedTracerNames = m_selectedTracerNames();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_cellFilter() == RigFlowDiagResults::CELLS_ACTIVE )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_flowDiagSolution )
|
2017-08-17 04:24:51 -05:00
|
|
|
{
|
|
|
|
selectedTracerNames = m_flowDiagSolution->tracerNames();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-24 02:27:08 -05:00
|
|
|
std::map<int, RigFlowDiagSolverInterface::FlowCharacteristicsResultFrame> timeStepToFlowResultMap;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( int timeStepIdx : m_currentlyPlottedTimeSteps )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_cellFilter() == RigFlowDiagResults::CELLS_VISIBLE )
|
2017-08-24 02:27:08 -05:00
|
|
|
{
|
|
|
|
cvf::UByteArray visibleCells;
|
2020-04-23 23:53:06 -05:00
|
|
|
m_case()->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
2017-08-24 02:27:08 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_cellFilterView )
|
2017-08-24 02:27:08 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_cellFilterView()->calculateCurrentTotalCellVisibility( &visibleCells, timeStepIdx );
|
2017-08-24 02:27:08 -05:00
|
|
|
}
|
|
|
|
|
2020-04-23 23:53:06 -05:00
|
|
|
RigActiveCellInfo* activeCellInfo =
|
|
|
|
m_case()->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<char> visibleActiveCells( activeCellInfo->reservoirActiveCellCount(), 0 );
|
2017-08-24 02:27:08 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( size_t i = 0; i < visibleCells.size(); ++i )
|
2017-08-24 02:27:08 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
size_t cellIndex = activeCellInfo->cellResultIndex( i );
|
|
|
|
if ( cellIndex != cvf::UNDEFINED_SIZE_T )
|
2017-08-24 02:27:08 -05:00
|
|
|
{
|
|
|
|
visibleActiveCells[cellIndex] = visibleCells[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-12 04:43:15 -06:00
|
|
|
auto flowCharResults =
|
|
|
|
flowResult->flowCharacteristicsResults( timeStepIdx, visibleActiveCells, m_maxPvFraction() );
|
2017-08-24 02:27:08 -05:00
|
|
|
timeStepToFlowResultMap[timeStepIdx] = flowCharResults;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto flowCharResults = flowResult->flowCharacteristicsResults( timeStepIdx,
|
|
|
|
m_cellFilter(),
|
|
|
|
selectedTracerNames,
|
|
|
|
m_maxPvFraction(),
|
|
|
|
m_minCommunication(),
|
|
|
|
m_maxTof() );
|
2017-08-24 02:27:08 -05:00
|
|
|
timeStepToFlowResultMap[timeStepIdx] = flowCharResults;
|
|
|
|
}
|
|
|
|
lorenzVals[timeStepIdx] = timeStepToFlowResultMap[timeStepIdx].m_lorenzCoefficient;
|
2017-03-28 16:35:53 -05:00
|
|
|
}
|
2017-08-24 02:27:08 -05:00
|
|
|
|
2019-06-23 08:18:17 -05:00
|
|
|
m_timeStepToFlowResultMap = timeStepToFlowResultMap;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_flowCharPlotWidget->setLorenzCurve( timeStepStrings, timeStepDates, lorenzVals );
|
2017-03-24 09:10:39 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( int timeStepIdx : m_currentlyPlottedTimeSteps )
|
2017-03-28 16:35:53 -05:00
|
|
|
{
|
2017-08-24 02:27:08 -05:00
|
|
|
const auto& flowCharResults = timeStepToFlowResultMap[timeStepIdx];
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_flowCharPlotWidget->addFlowCapStorageCapCurve( timeStepDates[timeStepIdx],
|
|
|
|
flowCharResults.m_storageCapFlowCapCurve.first,
|
|
|
|
flowCharResults.m_storageCapFlowCapCurve.second );
|
|
|
|
m_flowCharPlotWidget->addSweepEfficiencyCurve( timeStepDates[timeStepIdx],
|
|
|
|
flowCharResults.m_dimensionlessTimeSweepEfficiencyCurve.first,
|
|
|
|
flowCharResults.m_dimensionlessTimeSweepEfficiencyCurve.second );
|
2017-03-24 09:10:39 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_flowCharPlotWidget->showLegend( m_showLegend() );
|
2017-03-24 09:10:39 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-14 13:48:11 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// TODO: implement properly
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:13:38 -06:00
|
|
|
void RimFlowCharacteristicsPlot::assignIdIfNecessary()
|
|
|
|
{
|
|
|
|
}
|
2019-11-14 13:48:11 -06:00
|
|
|
|
2017-08-24 06:28:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-08-24 06:28:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimFlowCharacteristicsPlot::viewGeometryUpdated()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_cellFilter() == RigFlowDiagResults::CELLS_VISIBLE )
|
2017-08-24 06:28:17 -05:00
|
|
|
{
|
|
|
|
// Only need to reload data if cell filtering is based on visible cells in view.
|
2017-10-31 06:49:14 -05:00
|
|
|
onLoadDataAndUpdate();
|
2017-08-24 06:28:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-23 08:18:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-03 01:37:03 -06:00
|
|
|
double interpolate( const std::vector<double>& xData, const std::vector<double>& yData, double x, bool extrapolate )
|
2019-06-23 08:18:17 -05:00
|
|
|
{
|
|
|
|
size_t itemCount = xData.size();
|
|
|
|
|
|
|
|
size_t index = 0;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( x >= xData[itemCount - 2] )
|
2019-06-23 08:18:17 -05:00
|
|
|
{
|
|
|
|
index = itemCount - 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
while ( x > xData[index + 1] )
|
2019-06-23 08:18:17 -05:00
|
|
|
index++;
|
|
|
|
}
|
|
|
|
double xLeft = xData[index];
|
|
|
|
double yLeft = yData[index];
|
|
|
|
double xRight = xData[index + 1];
|
|
|
|
double yRight = yData[index + 1];
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !extrapolate )
|
2019-06-23 08:18:17 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( x < xLeft ) yRight = yLeft;
|
|
|
|
if ( x > xRight ) yLeft = yRight;
|
2019-06-23 08:18:17 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
double dydx = ( yRight - yLeft ) / ( xRight - xLeft );
|
2019-06-23 08:18:17 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
return yLeft + dydx * ( x - xLeft );
|
2019-06-23 08:18:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimFlowCharacteristicsPlot::curveDataAsText() const
|
|
|
|
{
|
2020-05-09 04:23:58 -05:00
|
|
|
QString fieldSeparator = RiaPreferences::current()->csvTextExportFieldSeparator;
|
2019-06-23 08:18:17 -05:00
|
|
|
QString tableText;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QTextStream stream( &tableText );
|
|
|
|
RifCsvDataTableFormatter formatter( stream, fieldSeparator );
|
2019-06-23 08:18:17 -05:00
|
|
|
|
2019-10-15 04:30:06 -05:00
|
|
|
std::vector<RifTextDataTableColumn> header = {
|
|
|
|
RifTextDataTableColumn( "Date" ),
|
|
|
|
RifTextDataTableColumn( "StorageCapacity" ),
|
|
|
|
RifTextDataTableColumn( "FlowCapacity" ),
|
|
|
|
RifTextDataTableColumn( "SweepEfficiency" ),
|
|
|
|
RifTextDataTableColumn( "DimensionlessTime" ),
|
|
|
|
RifTextDataTableColumn( "LorentzCoefficient" ),
|
2019-06-23 08:18:17 -05:00
|
|
|
};
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
formatter.header( header );
|
2019-06-23 08:18:17 -05:00
|
|
|
|
|
|
|
std::vector<QDateTime> timeStepDates = m_case->timeStepDates();
|
|
|
|
|
2020-11-06 03:46:38 -06:00
|
|
|
std::vector<double> storageCapacitySamplingValues = { 0.08, 0.1, 0.2, 0.3, 0.4 };
|
2019-06-23 08:18:17 -05:00
|
|
|
size_t sampleCount = storageCapacitySamplingValues.size();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( const auto& timeIndex : m_currentlyPlottedTimeSteps )
|
2019-06-23 08:18:17 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString dateString = timeStepDates[timeIndex].toString( "yyyy-MM-dd" );
|
2019-06-23 08:18:17 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
auto a = m_timeStepToFlowResultMap.find( timeIndex );
|
|
|
|
if ( a != m_timeStepToFlowResultMap.end() )
|
2019-06-23 08:18:17 -05:00
|
|
|
{
|
|
|
|
auto storageCapacityValues = a->second.m_storageCapFlowCapCurve.first;
|
|
|
|
auto flowCapacityValues = a->second.m_storageCapFlowCapCurve.second;
|
|
|
|
|
|
|
|
bool extrapolate = false;
|
|
|
|
std::vector<double> flowCapacitySamplingValues;
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( const auto storageCapacity : storageCapacitySamplingValues )
|
2019-06-23 08:18:17 -05:00
|
|
|
{
|
|
|
|
{
|
2020-02-12 04:43:15 -06:00
|
|
|
double flowCapacity =
|
|
|
|
interpolate( storageCapacityValues, flowCapacityValues, storageCapacity, extrapolate );
|
2019-09-06 03:40:57 -05:00
|
|
|
flowCapacitySamplingValues.push_back( flowCapacity );
|
2019-06-23 08:18:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto dimensionLessTimeValues = a->second.m_dimensionlessTimeSweepEfficiencyCurve.first;
|
|
|
|
auto sweepEffValues = a->second.m_dimensionlessTimeSweepEfficiencyCurve.second;
|
|
|
|
|
|
|
|
std::vector<double> dimensionLessTimeSamplingValues;
|
|
|
|
std::vector<double> sweepEffSamplingValues;
|
|
|
|
double range = dimensionLessTimeValues.back() - dimensionLessTimeValues[0];
|
|
|
|
double step = range / sampleCount;
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( size_t i = 0; i < sampleCount; i++ )
|
2019-06-23 08:18:17 -05:00
|
|
|
{
|
|
|
|
double dimensionLessTimeValue = i * step;
|
2019-09-06 03:40:57 -05:00
|
|
|
dimensionLessTimeSamplingValues.push_back( dimensionLessTimeValue );
|
2020-02-12 04:43:15 -06:00
|
|
|
double sweepEffValue =
|
|
|
|
interpolate( dimensionLessTimeValues, sweepEffValues, dimensionLessTimeValue, extrapolate );
|
2019-09-06 03:40:57 -05:00
|
|
|
sweepEffSamplingValues.push_back( sweepEffValue );
|
2019-06-23 08:18:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
auto lorentz = a->second.m_lorenzCoefficient;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( size_t i = 0; i < sampleCount; i++ )
|
2019-06-23 08:18:17 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
formatter.add( dateString );
|
|
|
|
formatter.add( storageCapacitySamplingValues[i] );
|
|
|
|
formatter.add( flowCapacitySamplingValues[i] );
|
|
|
|
formatter.add( sweepEffSamplingValues[i] );
|
|
|
|
formatter.add( dimensionLessTimeSamplingValues[i] );
|
|
|
|
formatter.add( lorentz );
|
2019-06-23 08:18:17 -05:00
|
|
|
formatter.rowCompleted();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
formatter.tableCompleted();
|
|
|
|
|
|
|
|
return tableText;
|
|
|
|
}
|
|
|
|
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-24 09:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
QWidget* RimFlowCharacteristicsPlot::createViewWidget( QWidget* mainWindowParent )
|
2017-03-24 09:10:39 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_flowCharPlotWidget = new RiuFlowCharacteristicsPlot( this, mainWindowParent );
|
2017-03-24 09:10:39 -05:00
|
|
|
return m_flowCharPlotWidget;
|
|
|
|
}
|