2012-05-18 09:45:23 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
2014-09-23 15:04:57 +02:00
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
2012-05-18 09:45:23 +02: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.
//
// 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.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
2015-06-25 13:05:28 +02:00
#include "RimEclipseResultDefinition.h"
2012-05-18 09:45:23 +02:00
2019-01-29 10:01:24 +01:00
#include "RiaLogging.h"
2017-01-09 19:14:07 +01:00
#include "RigActiveCellInfo.h"
2013-03-22 16:58:44 +01:00
#include "RigCaseCellResultsData.h"
2017-01-10 09:51:39 +01:00
#include "RigEclipseCaseData.h"
2017-01-12 11:13:33 +01:00
#include "RigFlowDiagResultAddress.h"
2018-09-28 13:21:02 +02:00
#include "RigFlowDiagResults.h"
2015-08-25 12:40:55 +02:00
2018-03-13 11:18:25 +01:00
#include "Rim3dView.h"
#include "Rim3dWellLogCurve.h"
2016-08-03 16:01:44 +02:00
#include "RimCellEdgeColors.h"
2019-01-11 13:03:46 +01:00
#include "RimEclipseContourMapProjection.h"
2015-05-15 09:16:33 +02:00
#include "RimEclipseCase.h"
2015-08-25 12:40:55 +02:00
#include "RimEclipseCellColors.h"
#include "RimEclipseFaultColors.h"
#include "RimEclipsePropertyFilter.h"
2017-01-12 11:13:33 +01:00
#include "RimEclipseResultCase.h"
2015-05-21 10:34:38 +02:00
#include "RimEclipseView.h"
2018-09-28 13:21:02 +02:00
#include "RimFlowDiagSolution.h"
2018-03-13 11:18:25 +01:00
#include "RimGridTimeHistoryCurve.h"
2018-02-01 17:45:22 +01:00
#include "RimIntersectionCollection.h"
2017-03-17 16:09:48 +01:00
#include "RimPlotCurve.h"
2015-08-25 12:40:55 +02:00
#include "RimReservoirCellResultsStorage.h"
2015-09-07 14:29:46 +02:00
#include "RimViewLinker.h"
2017-04-26 16:59:52 +02:00
#include "RimWellLogExtractionCurve.h"
2013-05-06 10:55:00 +02:00
2015-09-07 14:29:46 +02:00
#include "cafPdmUiListEditor.h"
2018-09-28 13:21:02 +02:00
#include "cafPdmUiToolButtonEditor.h"
2018-09-28 09:39:29 +02:00
#include "cafPdmUiTreeSelectionEditor.h"
2017-08-17 11:24:51 +02:00
#include "cafUtils.h"
2015-09-07 14:29:46 +02:00
2018-11-30 11:25:56 +01:00
#include <QDebug>
2018-09-27 22:29:04 +02:00
#include <QList>
2019-01-30 16:46:16 +01:00
#include "RimTools.h"
2018-09-27 22:29:04 +02:00
2017-01-12 11:13:33 +01:00
namespace caf
{
template <>
void RimEclipseResultDefinition :: FlowTracerSelectionEnum :: setUp ()
{
2017-05-02 11:25:15 +02:00
addItem ( RimEclipseResultDefinition :: FLOW_TR_INJ_AND_PROD , "FLOW_TR_INJ_AND_PROD" , "All Injectors and Producers" );
addItem ( RimEclipseResultDefinition :: FLOW_TR_PRODUCERS , "FLOW_TR_PRODUCERS" , "All Producers" );
addItem ( RimEclipseResultDefinition :: FLOW_TR_INJECTORS , "FLOW_TR_INJECTORS" , "All Injectors" );
2017-01-12 15:00:18 +01:00
addItem ( RimEclipseResultDefinition :: FLOW_TR_BY_SELECTION , "FLOW_TR_BY_SELECTION" , "By Selection" );
2017-01-12 11:13:33 +01:00
2017-01-12 15:00:18 +01:00
setDefault ( RimEclipseResultDefinition :: FLOW_TR_INJ_AND_PROD );
2017-01-12 11:13:33 +01:00
}
}
2016-12-16 14:17:56 +01:00
2015-06-25 09:38:53 +02:00
CAF_PDM_SOURCE_INIT ( RimEclipseResultDefinition , "ResultDefinition" );
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 09:38:53 +02:00
RimEclipseResultDefinition :: RimEclipseResultDefinition ()
2012-05-18 09:45:23 +02:00
{
CAF_PDM_InitObject ( "Result Definition" , "" , "" , "" );
2013-04-30 13:41:53 +02:00
CAF_PDM_InitFieldNoDefault ( & m_resultType , "ResultType" , "Type" , "" , "" , "" );
2015-08-05 13:27:36 +02:00
m_resultType . uiCapability () -> setUiHidden ( true );
2016-12-14 09:50:30 +01:00
2014-08-01 12:55:43 +02:00
CAF_PDM_InitFieldNoDefault ( & m_porosityModel , "PorosityModelType" , "Porosity" , "" , "" , "" );
2015-08-05 13:27:36 +02:00
m_porosityModel . uiCapability () -> setUiHidden ( true );
2016-12-14 09:50:30 +01:00
2017-06-13 15:41:52 +02:00
CAF_PDM_InitField ( & m_resultVariable , "ResultVariable" , RiaDefines :: undefinedResultName (), "Variable" , "" , "" , "" );
2015-08-05 13:27:36 +02:00
m_resultVariable . uiCapability () -> setUiHidden ( true );
2012-06-26 16:10:41 +02:00
2016-12-14 09:50:30 +01:00
CAF_PDM_InitFieldNoDefault ( & m_flowSolution , "FlowDiagSolution" , "Solution" , "" , "" , "" );
m_flowSolution . uiCapability () -> setUiHidden ( true );
2019-01-30 16:46:16 +01:00
CAF_PDM_InitField ( & m_isTimeLapseResult , "IsTimeLapseResult" , false , "TimeLapseResult" , "" , "" , "" );
m_isTimeLapseResult . uiCapability () -> setUiHidden ( true );
CAF_PDM_InitField ( & m_timeLapseBaseTimestep , "TimeLapseBaseTimeStep" , 0 , "Base Time Step" , "" , "" , "" );
m_timeLapseBaseTimestep . uiCapability () -> setUiHidden ( true );
2018-09-27 15:11:49 +02:00
// One single tracer list has been split into injectors and producers.
// The old list is defined as injectors and we'll have to move any producers in old projects.
CAF_PDM_InitFieldNoDefault ( & m_selectedTracers_OBSOLETE , "SelectedTracers" , "Tracers" , "" , "" , "" );
m_selectedTracers_OBSOLETE . uiCapability () -> setUiHidden ( true );
2018-09-28 09:39:29 +02:00
CAF_PDM_InitFieldNoDefault ( & m_selectedInjectorTracers , "SelectedInjectorTracers" , "Injector Tracers" , "" , "" , "" );
2018-09-27 15:11:49 +02:00
m_selectedInjectorTracers . uiCapability () -> setUiHidden ( true );
2018-09-28 09:39:29 +02:00
CAF_PDM_InitFieldNoDefault ( & m_selectedProducerTracers , "SelectedProducerTracers" , "Producer Tracers" , "" , "" , "" );
2018-09-27 15:11:49 +02:00
m_selectedProducerTracers . uiCapability () -> setUiHidden ( true );
2016-12-14 09:50:30 +01:00
2017-08-31 16:22:50 +02:00
CAF_PDM_InitFieldNoDefault ( & m_selectedSouringTracers , "SelectedSouringTracers" , "Tracers" , "" , "" , "" );
m_selectedSouringTracers . uiCapability () -> setUiHidden ( true );
2017-01-12 15:00:18 +01:00
CAF_PDM_InitFieldNoDefault ( & m_flowTracerSelectionMode , "FlowTracerSelectionMode" , "Tracers" , "" , "" , "" );
2017-08-10 15:08:30 +02:00
CAF_PDM_InitFieldNoDefault ( & m_phaseSelection , "PhaseSelection" , "Phases" , "" , "" , "" );
2017-01-12 11:13:33 +01:00
2016-12-14 09:50:30 +01:00
// Ui only fields
2013-04-30 13:41:53 +02:00
CAF_PDM_InitFieldNoDefault ( & m_resultTypeUiField , "MResultType" , "Type" , "" , "" , "" );
2018-11-05 14:27:34 +01:00
m_resultTypeUiField . xmlCapability () -> disableIO ();
2016-12-14 09:50:30 +01:00
2014-08-01 12:55:43 +02:00
CAF_PDM_InitFieldNoDefault ( & m_porosityModelUiField , "MPorosityModelType" , "Porosity" , "" , "" , "" );
2018-11-05 14:27:34 +01:00
m_porosityModelUiField . xmlCapability () -> disableIO ();
2016-12-14 09:50:30 +01:00
2017-11-30 13:44:18 +01:00
CAF_PDM_InitField ( & m_resultVariableUiField , "MResultVariable" , RiaDefines :: undefinedResultName (), "Result Property" , "" , "" , "" );
2018-11-05 14:27:34 +01:00
m_resultVariableUiField . xmlCapability () -> disableIO ();
2016-12-14 09:50:30 +01:00
m_resultVariableUiField . uiCapability () -> setUiEditorTypeName ( caf :: PdmUiListEditor :: uiEditorTypeName ());
2013-04-30 13:41:53 +02:00
2019-01-30 16:46:16 +01:00
CAF_PDM_InitField ( & m_isTimeLapseResultUiField , "IsTimeLapseResultUI" , false , "Enable Relative Result" , "" , "Use the difference with respect to a specific time step as the result variable to plot" , "" );
m_isTimeLapseResultUiField . xmlCapability () -> disableIO ();
CAF_PDM_InitField ( & m_timeLapseBaseTimestepUiField , "TimeLapseBaseTimeStepUI" , 0 , "Base Time Step" , "" , "" , "" );
m_timeLapseBaseTimestepUiField . xmlCapability () -> disableIO ();
2017-01-12 11:13:33 +01:00
2016-12-14 09:50:30 +01:00
CAF_PDM_InitFieldNoDefault ( & m_flowSolutionUiField , "MFlowDiagSolution" , "Solution" , "" , "" , "" );
2018-11-05 14:27:34 +01:00
m_flowSolutionUiField . xmlCapability () -> disableIO ();
2017-04-06 10:59:52 +02:00
m_flowSolutionUiField . uiCapability () -> setUiHidden ( true ); // For now since there are only one to choose from
2018-09-28 13:21:02 +02:00
CAF_PDM_InitField ( & m_syncInjectorToProducerSelection , "MSyncSelectedInjProd" , false , "Add Communicators ->" , "" , "" , "" );
m_syncInjectorToProducerSelection . uiCapability () -> setUiEditorTypeName ( caf :: PdmUiToolButtonEditor :: uiEditorTypeName ());
CAF_PDM_InitField ( & m_syncProducerToInjectorSelection , "MSyncSelectedProdInj" , false , "<- Add Communicators" , "" , "" , "" );
m_syncProducerToInjectorSelection . uiCapability () -> setUiEditorTypeName ( caf :: PdmUiToolButtonEditor :: uiEditorTypeName ());
2018-09-27 15:11:49 +02:00
CAF_PDM_InitFieldNoDefault ( & m_selectedInjectorTracersUiField , "MSelectedInjectorTracers" , "Injector Tracers" , "" , "" , "" );
2018-11-05 14:27:34 +01:00
m_selectedInjectorTracersUiField . xmlCapability () -> disableIO ();
2018-09-28 09:39:29 +02:00
m_selectedInjectorTracersUiField . uiCapability () -> setUiEditorTypeName ( caf :: PdmUiTreeSelectionEditor :: uiEditorTypeName ());
2018-09-27 15:11:49 +02:00
m_selectedInjectorTracersUiField . uiCapability () -> setUiLabelPosition ( caf :: PdmUiItemInfo :: HIDDEN );
CAF_PDM_InitFieldNoDefault ( & m_selectedProducerTracersUiField , "MSelectedProducerTracers" , "Producer Tracers" , "" , "" , "" );
2018-11-05 14:27:34 +01:00
m_selectedProducerTracersUiField . xmlCapability () -> disableIO ();
2018-09-28 09:39:29 +02:00
m_selectedProducerTracersUiField . uiCapability () -> setUiEditorTypeName ( caf :: PdmUiTreeSelectionEditor :: uiEditorTypeName ());
2018-09-27 15:11:49 +02:00
m_selectedProducerTracersUiField . uiCapability () -> setUiLabelPosition ( caf :: PdmUiItemInfo :: HIDDEN );
2017-08-31 16:22:50 +02:00
CAF_PDM_InitFieldNoDefault ( & m_selectedSouringTracersUiField , "MSelectedSouringTracers" , "Tracers" , "" , "" , "" );
2018-11-05 14:27:34 +01:00
m_selectedSouringTracersUiField . xmlCapability () -> disableIO ();
2017-08-31 16:22:50 +02:00
m_selectedSouringTracersUiField . uiCapability () -> setUiEditorTypeName ( caf :: PdmUiListEditor :: uiEditorTypeName ());
2012-05-18 09:45:23 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 09:38:53 +02:00
RimEclipseResultDefinition ::~ RimEclipseResultDefinition ()
2012-05-18 09:45:23 +02:00
{
}
2016-12-20 14:33:35 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: simpleCopy ( const RimEclipseResultDefinition * other )
{
this -> setResultVariable ( other -> resultVariable ());
this -> setPorosityModel ( other -> porosityModel ());
this -> setResultType ( other -> resultType ());
this -> setFlowSolution ( other -> m_flowSolution ());
2018-09-27 15:11:49 +02:00
this -> setSelectedInjectorTracers ( other -> m_selectedInjectorTracers ());
this -> setSelectedProducerTracers ( other -> m_selectedProducerTracers ());
2017-08-31 16:22:50 +02:00
this -> setSelectedSouringTracers ( other -> m_selectedSouringTracers ());
2017-02-09 15:32:14 +01:00
m_flowTracerSelectionMode = other -> m_flowTracerSelectionMode ();
2017-08-10 15:08:30 +02:00
m_phaseSelection = other -> m_phaseSelection ;
2016-12-20 14:33:35 +01:00
}
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-09-01 13:56:35 +02:00
void RimEclipseResultDefinition :: setEclipseCase ( RimEclipseCase * eclipseCase )
2012-05-18 09:45:23 +02:00
{
2015-09-01 13:56:35 +02:00
m_eclipseCase = eclipseCase ;
2017-04-24 09:52:28 +02:00
assignFlowSolutionFromCase ();
2012-05-18 09:45:23 +02:00
}
2013-04-30 13:41:53 +02:00
2016-10-14 11:52:09 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-09-13 10:39:20 +02:00
RigCaseCellResultsData * RimEclipseResultDefinition :: currentGridCellResults () const
2013-04-30 13:41:53 +02:00
{
2016-10-21 13:57:15 +02:00
if ( ! m_eclipseCase ) return nullptr ;
2013-04-30 13:41:53 +02:00
2017-09-13 10:39:20 +02:00
return m_eclipseCase -> results ( m_porosityModel ());
2013-04-30 13:41:53 +02:00
}
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 09:38:53 +02:00
void RimEclipseResultDefinition :: fieldChangedByUi ( const caf :: PdmFieldHandle * changedField , const QVariant & oldValue , const QVariant & newValue )
2012-05-18 09:45:23 +02:00
{
2016-12-20 14:33:35 +01:00
if ( & m_flowSolutionUiField == changedField
|| & m_resultTypeUiField == changedField
2013-04-30 13:41:53 +02:00
|| & m_porosityModelUiField == changedField )
2012-05-18 09:45:23 +02:00
{
2016-12-20 14:33:35 +01:00
// If the user are seeing the list with the actually selected result,
// select that result in the list. Otherwise select nothing.
2016-12-14 09:50:30 +01:00
QStringList varList = getResultNamesForCurrentUiResultType ();
2013-04-30 13:41:53 +02:00
2017-06-13 15:41:52 +02:00
bool isFlowDiagFieldsRelevant = ( m_resultType () == RiaDefines :: FLOW_DIAGNOSTICS );
2016-12-20 14:33:35 +01:00
if ( ( m_flowSolutionUiField () == m_flowSolution () || ! isFlowDiagFieldsRelevant )
&& m_resultTypeUiField () == m_resultType ()
&& m_porosityModelUiField () == m_porosityModel () )
2013-04-30 13:41:53 +02:00
{
2016-12-20 14:33:35 +01:00
if ( varList . contains ( resultVariable ()))
{
m_resultVariableUiField = resultVariable ();
}
2018-09-27 15:11:49 +02:00
if ( isFlowDiagFieldsRelevant )
{
m_selectedInjectorTracersUiField = m_selectedInjectorTracers ();
m_selectedProducerTracersUiField = m_selectedProducerTracers ();
}
else
{
m_selectedInjectorTracersUiField = std :: vector < QString > ();
m_selectedProducerTracersUiField = std :: vector < QString > ();
}
2013-04-30 13:41:53 +02:00
}
else
{
m_resultVariableUiField = "" ;
2018-09-27 15:11:49 +02:00
m_selectedInjectorTracersUiField = std :: vector < QString > ();
m_selectedProducerTracersUiField = std :: vector < QString > ();
2013-04-30 13:41:53 +02:00
}
2012-05-18 09:45:23 +02:00
}
2015-09-02 09:17:36 +02:00
2013-04-30 13:41:53 +02:00
if ( & m_resultVariableUiField == changedField )
{
2015-09-01 13:56:35 +02:00
m_porosityModel = m_porosityModelUiField ;
m_resultType = m_resultTypeUiField ;
2013-04-30 13:41:53 +02:00
m_resultVariable = m_resultVariableUiField ;
2019-01-30 16:46:16 +01:00
m_isTimeLapseResult = m_isTimeLapseResultUiField ;
m_timeLapseBaseTimestep = m_timeLapseBaseTimestepUiField ;
2015-08-10 14:14:22 +02:00
2017-06-13 15:41:52 +02:00
if ( m_resultTypeUiField () == RiaDefines :: FLOW_DIAGNOSTICS )
2016-12-14 09:50:30 +01:00
{
m_flowSolution = m_flowSolutionUiField ();
2018-09-27 15:11:49 +02:00
m_selectedInjectorTracers = m_selectedInjectorTracersUiField ();
m_selectedProducerTracers = m_selectedProducerTracersUiField ();
2016-12-14 09:50:30 +01:00
}
2017-08-31 16:22:50 +02:00
else if ( m_resultTypeUiField () == RiaDefines :: INJECTION_FLOODING )
{
m_selectedSouringTracers = m_selectedSouringTracersUiField ();
}
2017-02-15 10:40:32 +01:00
loadDataAndUpdate ();
2016-12-14 09:50:30 +01:00
}
2019-01-30 16:46:16 +01:00
if ( & m_isTimeLapseResultUiField == changedField )
{
if ( m_isTimeLapseResultUiField () && m_timeLapseBaseTimestep () == RigFemResultAddress :: NO_TIME_LAPSE )
{
m_timeLapseBaseTimestepUiField = 0 ;
}
m_resultVariableUiField = "" ;
}
2018-09-28 09:39:29 +02:00
if ( & m_flowTracerSelectionMode == changedField )
2016-12-14 09:50:30 +01:00
{
2018-09-28 09:39:29 +02:00
loadDataAndUpdate ();
2018-09-27 15:11:49 +02:00
}
2017-03-27 11:24:51 +02:00
2018-09-28 09:39:29 +02:00
if ( & m_selectedInjectorTracersUiField == changedField )
2018-09-27 15:11:49 +02:00
{
changedTracerSelectionField ( true );
}
2017-03-27 11:24:51 +02:00
2018-09-27 15:11:49 +02:00
if ( & m_selectedProducerTracersUiField == changedField )
{
changedTracerSelectionField ( false );
2016-10-21 13:57:15 +02:00
}
2015-08-10 14:14:22 +02:00
2018-09-28 13:21:02 +02:00
if ( & m_syncInjectorToProducerSelection == changedField )
{
syncInjectorToProducerSelection ();
m_syncInjectorToProducerSelection = false ;
}
if ( & m_syncProducerToInjectorSelection == changedField )
{
syncProducerToInjectorSelection ();
m_syncProducerToInjectorSelection = false ;
}
2018-09-27 15:11:49 +02:00
2017-08-31 16:22:50 +02:00
if ( & m_selectedSouringTracersUiField == changedField )
{
if ( ! m_resultVariable (). isEmpty ())
{
m_selectedSouringTracers = m_selectedSouringTracersUiField ();
loadDataAndUpdate ();
}
}
2017-08-10 15:08:30 +02:00
if ( & m_phaseSelection == changedField )
{
2017-08-22 12:04:10 +02:00
if ( m_phaseSelection () != RigFlowDiagResultAddress :: PHASE_ALL )
{
2017-08-29 15:21:07 +02:00
m_resultType = m_resultTypeUiField ;
2017-08-22 12:04:10 +02:00
m_resultVariable = RIG_FLD_TOF_RESNAME ;
m_resultVariableUiField = RIG_FLD_TOF_RESNAME ;
}
2017-08-10 15:08:30 +02:00
loadDataAndUpdate ();
}
2018-09-27 15:11:49 +02:00
updateAnyFieldHasChanged ();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: changedTracerSelectionField ( bool injector )
{
m_flowSolution = m_flowSolutionUiField ();
std :: vector < QString >& selectedTracers = injector ? m_selectedInjectorTracers . v ()
: m_selectedProducerTracers . v ();
std :: vector < QString >& selectedTracersUi = injector ? m_selectedInjectorTracersUiField . v ()
: m_selectedProducerTracersUiField . v ();
2017-03-27 11:24:51 +02:00
2018-09-28 09:39:29 +02:00
selectedTracers = selectedTracersUi ;
2018-09-27 15:11:49 +02:00
loadDataAndUpdate ();
2016-10-21 13:57:15 +02:00
}
2015-09-01 13:56:35 +02:00
2016-10-21 13:57:15 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: updateAnyFieldHasChanged ()
{
RimEclipsePropertyFilter * propFilter = nullptr ;
this -> firstAncestorOrThisOfType ( propFilter );
if ( propFilter )
{
propFilter -> updateConnectedEditors ();
}
RimEclipseFaultColors * faultColors = nullptr ;
this -> firstAncestorOrThisOfType ( faultColors );
if ( faultColors )
{
faultColors -> updateConnectedEditors ();
}
2015-08-10 14:14:22 +02:00
2016-10-21 13:57:15 +02:00
RimCellEdgeColors * cellEdgeColors = nullptr ;
this -> firstAncestorOrThisOfType ( cellEdgeColors );
if ( cellEdgeColors )
{
cellEdgeColors -> updateConnectedEditors ();
}
2016-09-07 11:41:02 +02:00
2016-10-21 13:57:15 +02:00
RimEclipseCellColors * cellColors = nullptr ;
this -> firstAncestorOrThisOfType ( cellColors );
if ( cellColors )
{
cellColors -> updateConnectedEditors ();
}
2015-09-02 09:17:36 +02:00
2017-03-17 16:09:48 +01:00
RimPlotCurve * curve = nullptr ;
2016-10-21 13:57:15 +02:00
this -> firstAncestorOrThisOfType ( curve );
if ( curve )
{
curve -> updateConnectedEditors ();
}
2018-03-13 11:18:25 +01:00
Rim3dWellLogCurve * rim3dWellLogCurve = nullptr ;
this -> firstAncestorOrThisOfType ( rim3dWellLogCurve );
if ( rim3dWellLogCurve )
{
2018-04-19 13:42:53 +02:00
rim3dWellLogCurve -> resetMinMaxValuesAndUpdateUI ();
2018-03-13 11:18:25 +01:00
}
2018-11-09 15:25:35 +01:00
2019-01-11 13:03:46 +01:00
RimEclipseContourMapProjection * contourMap = nullptr ;
2018-11-09 15:25:35 +01:00
this -> firstAncestorOrThisOfType ( contourMap );
if ( contourMap )
{
contourMap -> updatedWeightingResult ();
}
2016-10-21 13:57:15 +02:00
}
2016-08-06 08:44:49 +02:00
2017-02-13 15:00:49 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: setTofAndSelectTracer ( const QString & tracerName )
{
2017-06-13 15:41:52 +02:00
setResultType ( RiaDefines :: FLOW_DIAGNOSTICS );
2017-02-13 15:00:49 +01:00
setResultVariable ( "TOF" );
2017-03-02 16:10:18 +01:00
setFlowDiagTracerSelectionType ( FLOW_TR_BY_SELECTION );
2017-02-13 15:00:49 +01:00
if ( m_flowSolution () == nullptr )
{
assignFlowSolutionFromCase ();
}
2018-09-27 15:11:49 +02:00
if ( m_flowSolution ())
{
RimFlowDiagSolution :: TracerStatusType tracerStatus = m_flowSolution () -> tracerStatusOverall ( tracerName );
std :: vector < QString > tracers ;
tracers . push_back ( tracerName );
if ( tracerStatus == RimFlowDiagSolution :: INJECTOR )
{
setSelectedInjectorTracers ( tracers );
}
else if ( tracerStatus == RimFlowDiagSolution :: PRODUCER )
{
setSelectedProducerTracers ( tracers );
}
}
2017-02-13 15:00:49 +01:00
}
2016-10-21 13:57:15 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-02-15 10:40:32 +01:00
void RimEclipseResultDefinition :: loadDataAndUpdate ()
2016-10-21 13:57:15 +02:00
{
2018-01-09 10:11:28 +01:00
Rim3dView * view = nullptr ;
2016-10-21 13:57:15 +02:00
this -> firstAncestorOrThisOfType ( view );
2016-08-06 08:44:49 +02:00
2016-10-21 13:57:15 +02:00
loadResult ();
2015-08-10 14:14:22 +02:00
2016-10-21 13:57:15 +02:00
RimEclipsePropertyFilter * propFilter = nullptr ;
this -> firstAncestorOrThisOfType ( propFilter );
2015-08-10 14:14:22 +02:00
if ( propFilter )
{
2016-10-21 13:57:15 +02:00
propFilter -> setToDefaultValues ();
propFilter -> updateFilterName ();
if ( view )
{
view -> scheduleGeometryRegen ( PROPERTY_FILTERED );
view -> scheduleCreateDisplayModelAndRedraw ();
}
2015-08-10 14:14:22 +02:00
}
2016-10-21 13:57:15 +02:00
RimEclipseCellColors * cellColors = nullptr ;
this -> firstAncestorOrThisOfType ( cellColors );
if ( cellColors )
2015-08-10 14:14:22 +02:00
{
2016-10-21 13:57:15 +02:00
this -> updateLegendCategorySettings ();
if ( view )
{
RimViewLinker * viewLinker = view -> assosiatedViewLinker ();
if ( viewLinker )
{
viewLinker -> updateCellResult ();
}
2018-02-01 17:45:22 +01:00
RimGridView * eclView = dynamic_cast < RimGridView *> ( view );
if ( eclView ) eclView -> crossSectionCollection () -> scheduleCreateDisplayModelAndRedraw2dIntersectionViews ();
2016-10-21 13:57:15 +02:00
}
2013-04-30 13:41:53 +02:00
}
2015-09-02 09:17:36 +02:00
2016-10-21 13:57:15 +02:00
RimCellEdgeColors * cellEdgeColors = nullptr ;
this -> firstAncestorOrThisOfType ( cellEdgeColors );
2016-08-03 16:01:44 +02:00
if ( cellEdgeColors )
{
2016-10-21 13:57:15 +02:00
cellEdgeColors -> singleVarEdgeResultColors () -> updateLegendCategorySettings ();
cellEdgeColors -> loadResult ();
if ( view )
{
view -> scheduleCreateDisplayModelAndRedraw ();
}
2016-08-03 16:01:44 +02:00
}
2017-03-17 16:09:48 +01:00
RimPlotCurve * curve = nullptr ;
2016-10-21 13:57:15 +02:00
this -> firstAncestorOrThisOfType ( curve );
2015-09-02 09:17:36 +02:00
if ( curve )
{
2017-09-23 08:47:04 +02:00
curve -> loadDataAndUpdate ( true );
2015-09-02 09:17:36 +02:00
}
2018-03-13 11:18:25 +01:00
Rim3dWellLogCurve * rim3dWellLogCurve = nullptr ;
this -> firstAncestorOrThisOfType ( rim3dWellLogCurve );
if ( rim3dWellLogCurve )
{
rim3dWellLogCurve -> updateCurveIn3dView ();
}
2012-05-18 09:45:23 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 09:38:53 +02:00
QList < caf :: PdmOptionItemInfo > RimEclipseResultDefinition :: calculateValueOptions ( const caf :: PdmFieldHandle * fieldNeedingOptions , bool * useOptionsOnly )
2014-09-08 07:53:49 +02:00
{
2017-01-05 07:57:37 +01:00
QList < caf :: PdmOptionItemInfo > options ;
2016-08-06 08:44:49 +02:00
2017-01-12 14:16:39 +01:00
if ( fieldNeedingOptions == & m_resultTypeUiField )
{
2017-07-07 13:31:14 +02:00
bool hasSourSimRLFile = false ;
2017-01-12 14:16:39 +01:00
RimEclipseResultCase * eclResCase = dynamic_cast < RimEclipseResultCase *> ( m_eclipseCase . p ());
2017-03-15 09:10:16 +01:00
if ( eclResCase && eclResCase -> eclipseCaseData () )
2017-01-12 14:16:39 +01:00
{
2017-07-07 13:31:14 +02:00
hasSourSimRLFile = eclResCase -> hasSourSimFile ();
2017-01-12 14:16:39 +01:00
}
2017-08-11 15:49:38 +02:00
#ifndef USE_HDF5
// If using ResInsight without HDF5 support, ignore SourSim files and
// do not show it as a result category.
hasSourSimRLFile = false ;
#endif
2017-08-31 16:22:50 +02:00
bool enableSouring = false ;
#ifdef ENABLE_SOURING
2018-01-30 13:48:28 +01:00
if ( m_eclipseCase . notNull ())
2018-01-25 18:24:12 +01:00
{
2018-01-30 13:48:28 +01:00
RigCaseCellResultsData * cellResultsData = m_eclipseCase -> results ( this -> porosityModel ());
2018-01-25 18:24:12 +01:00
2018-01-30 13:48:28 +01:00
if ( cellResultsData -> hasFlowDiagUsableFluxes ())
{
enableSouring = true ;
}
}
2017-08-31 16:22:50 +02:00
#endif /* ENABLE_SOURING */
2017-07-07 13:31:14 +02:00
2017-04-26 17:07:39 +02:00
RimGridTimeHistoryCurve * timeHistoryCurve ;
this -> firstAncestorOrThisOfType ( timeHistoryCurve );
2017-01-12 14:16:39 +01:00
2017-08-14 10:47:44 +02:00
// Do not include flow diagnostics results if it is a time history curve
2017-08-17 15:01:48 +02:00
// Do not include SourSimRL if no SourSim file is loaded
2017-08-31 16:22:50 +02:00
if ( timeHistoryCurve != nullptr || ! hasSourSimRLFile || ! enableSouring )
2017-01-12 14:16:39 +01:00
{
2017-06-13 15:41:52 +02:00
using ResCatEnum = caf :: AppEnum < RiaDefines :: ResultCatType > ;
2017-01-23 13:51:44 +01:00
for ( size_t i = 0 ; i < ResCatEnum :: size (); ++ i )
2017-01-12 14:16:39 +01:00
{
2017-06-13 15:41:52 +02:00
RiaDefines :: ResultCatType resType = ResCatEnum :: fromIndex ( i );
2017-08-14 10:47:44 +02:00
if ( resType == RiaDefines :: FLOW_DIAGNOSTICS
&& ( timeHistoryCurve ) )
2017-07-07 13:31:14 +02:00
{
continue ;
}
2017-08-14 10:47:44 +02:00
if ( resType == RiaDefines :: SOURSIMRL
2017-07-07 13:31:14 +02:00
&& ( ! hasSourSimRLFile ) )
2017-01-12 14:16:39 +01:00
{
2017-07-07 13:31:14 +02:00
continue ;
2017-01-12 14:16:39 +01:00
}
2017-07-07 13:31:14 +02:00
2017-08-31 16:22:50 +02:00
if ( resType == RiaDefines :: INJECTION_FLOODING && ! enableSouring )
{
continue ;
}
2017-07-07 13:31:14 +02:00
QString uiString = ResCatEnum :: uiTextFromIndex ( i );
options . push_back ( caf :: PdmOptionItemInfo ( uiString , resType ));
2017-01-12 14:16:39 +01:00
}
}
}
2017-08-31 16:22:50 +02:00
if ( m_resultTypeUiField () == RiaDefines :: FLOW_DIAGNOSTICS )
2015-08-25 08:43:20 +02:00
{
2016-12-14 09:50:30 +01:00
if ( fieldNeedingOptions == & m_resultVariableUiField )
{
2018-11-21 13:32:55 +01:00
options . push_back ( caf :: PdmOptionItemInfo ( timeOfFlightString ( false ), RIG_FLD_TOF_RESNAME ));
2017-08-16 10:10:12 +02:00
if ( m_phaseSelection () == RigFlowDiagResultAddress :: PHASE_ALL )
{
options . push_back ( caf :: PdmOptionItemInfo ( "Tracer Cell Fraction (Sum)" , RIG_FLD_CELL_FRACTION_RESNAME ));
2018-11-21 13:32:55 +01:00
options . push_back ( caf :: PdmOptionItemInfo ( maxFractionTracerString ( false ), RIG_FLD_MAX_FRACTION_TRACER_RESNAME ));
2017-08-16 10:10:12 +02:00
options . push_back ( caf :: PdmOptionItemInfo ( "Injector Producer Communication" , RIG_FLD_COMMUNICATION_RESNAME ));
}
2016-12-14 09:50:30 +01:00
}
else if ( fieldNeedingOptions == & m_flowSolutionUiField )
{
2017-04-24 09:52:28 +02:00
RimEclipseResultCase * eclCase = dynamic_cast < RimEclipseResultCase *> ( m_eclipseCase . p ());
2016-12-14 09:50:30 +01:00
if ( eclCase )
{
std :: vector < RimFlowDiagSolution *> flowSols = eclCase -> flowDiagSolutions ();
for ( RimFlowDiagSolution * flowSol : flowSols )
{
2017-01-05 07:57:37 +01:00
options . push_back ( caf :: PdmOptionItemInfo ( flowSol -> userDescription (), flowSol ));
2016-12-14 09:50:30 +01:00
}
}
}
2018-09-27 15:11:49 +02:00
else if ( fieldNeedingOptions == & m_selectedInjectorTracersUiField )
2016-12-14 09:50:30 +01:00
{
2018-09-27 15:11:49 +02:00
options = calcOptionsForSelectedTracerField ( true );
}
else if ( fieldNeedingOptions == & m_selectedProducerTracersUiField )
{
options = calcOptionsForSelectedTracerField ( false );
2016-12-14 09:50:30 +01:00
}
2015-08-25 08:43:20 +02:00
}
2017-08-31 16:22:50 +02:00
else if ( m_resultTypeUiField () == RiaDefines :: INJECTION_FLOODING )
{
if ( fieldNeedingOptions == & m_selectedSouringTracersUiField )
{
2017-09-13 10:39:20 +02:00
RigCaseCellResultsData * cellResultsStorage = currentGridCellResults ();
if ( cellResultsStorage )
2017-08-31 16:22:50 +02:00
{
2017-09-13 10:39:20 +02:00
QStringList dynamicResultNames = cellResultsStorage -> resultNames ( RiaDefines :: DYNAMIC_NATIVE );
2017-08-31 16:22:50 +02:00
for ( const QString & resultName : dynamicResultNames )
{
2017-11-27 14:33:31 +01:00
if ( ! resultName . endsWith ( "F" ) ||
2017-08-31 16:22:50 +02:00
resultName == RiaDefines :: completionTypeResultName ())
{
continue ;
}
options . push_back ( caf :: PdmOptionItemInfo ( resultName , resultName ));
}
}
}
else if ( fieldNeedingOptions == & m_resultVariableUiField )
{
options . push_back ( caf :: PdmOptionItemInfo ( RIG_NUM_FLOODED_PV , RIG_NUM_FLOODED_PV ));
}
}
else
{
if ( fieldNeedingOptions == & m_resultVariableUiField )
{
options = calcOptionsForVariableUiFieldStandard ();
}
2019-01-30 16:46:16 +01:00
else if ( fieldNeedingOptions == & m_timeLapseBaseTimestepUiField )
{
std :: vector < QDateTime > stepDates ;
const RigCaseCellResultsData * gridCellResults = this -> currentGridCellResults ();
if ( gridCellResults )
{
stepDates = gridCellResults -> timeStepDates ();
}
for ( size_t stepIdx = 0 ; stepIdx < stepDates . size (); ++ stepIdx )
{
options . push_back ( caf :: PdmOptionItemInfo ( stepDates [ stepIdx ]. toString ( RimTools :: dateFormatString ()),
static_cast < int > ( stepIdx )));
}
}
2017-08-31 16:22:50 +02:00
}
2015-08-25 08:43:20 +02:00
2016-12-14 09:50:30 +01:00
( * useOptionsOnly ) = true ;
2017-01-05 07:57:37 +01:00
return options ;
2014-09-08 07:53:49 +02:00
}
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2019-01-23 14:24:12 +01:00
RigEclipseResultAddress RimEclipseResultDefinition :: eclipseResultAddress () const
2012-05-18 09:45:23 +02:00
{
2019-01-22 08:54:00 +01:00
if ( isFlowDiagOrInjectionFlooding ()) return RigEclipseResultAddress ();
2016-12-20 14:33:35 +01:00
2017-09-13 10:39:20 +02:00
const RigCaseCellResultsData * gridCellResults = this -> currentGridCellResults ();
if ( gridCellResults )
2015-09-01 19:55:37 +02:00
{
2019-01-30 16:46:16 +01:00
if ( m_isTimeLapseResult ())
return RigEclipseResultAddress ( m_resultType (), m_resultVariable (), m_timeLapseBaseTimestep ());
else
return RigEclipseResultAddress ( m_resultType (), m_resultVariable ());
2019-01-25 12:58:07 +01:00
}
else
{
return RigEclipseResultAddress ();
2015-09-01 19:55:37 +02:00
}
2012-05-18 09:45:23 +02:00
}
2016-12-16 14:17:56 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFlowDiagResultAddress RimEclipseResultDefinition :: flowDiagResAddress () const
{
2017-10-18 11:31:19 +02:00
CVF_ASSERT ( isFlowDiagOrInjectionFlooding ());
2017-02-24 16:00:56 +01:00
2017-08-31 16:22:50 +02:00
if ( m_resultType () == RiaDefines :: FLOW_DIAGNOSTICS )
2017-04-26 16:59:52 +02:00
{
2017-08-31 16:22:50 +02:00
size_t timeStep = 0 ;
2017-01-12 11:13:33 +01:00
2018-01-09 10:11:28 +01:00
Rim3dView * rimView = nullptr ;
2017-08-31 16:22:50 +02:00
this -> firstAncestorOrThisOfType ( rimView );
if ( rimView )
2017-01-12 11:13:33 +01:00
{
2017-08-31 16:22:50 +02:00
timeStep = rimView -> currentTimeStep ();
2017-01-12 11:13:33 +01:00
}
2017-08-31 16:22:50 +02:00
RimWellLogExtractionCurve * wellLogExtractionCurve = nullptr ;
this -> firstAncestorOrThisOfType ( wellLogExtractionCurve );
if ( wellLogExtractionCurve )
2017-01-12 11:13:33 +01:00
{
2017-08-31 16:22:50 +02:00
timeStep = static_cast < size_t > ( wellLogExtractionCurve -> currentTimeStep ());
}
2017-01-12 11:13:33 +01:00
2017-08-31 16:22:50 +02:00
// Time history curves are not supported, since it requires the time
// step to access to be supplied.
RimGridTimeHistoryCurve * timeHistoryCurve = nullptr ;
this -> firstAncestorOrThisOfType ( timeHistoryCurve );
CVF_ASSERT ( timeHistoryCurve == nullptr );
std :: set < std :: string > selTracerNames ;
if ( m_flowTracerSelectionMode == FLOW_TR_BY_SELECTION )
{
2018-09-27 15:11:49 +02:00
for ( const QString & tName : m_selectedInjectorTracers ())
{
selTracerNames . insert ( tName . toStdString ());
}
for ( const QString & tName : m_selectedProducerTracers ())
2017-01-12 11:13:33 +01:00
{
2017-08-31 16:22:50 +02:00
selTracerNames . insert ( tName . toStdString ());
}
}
else
{
RimFlowDiagSolution * flowSol = m_flowSolution ();
if ( flowSol )
{
std :: vector < QString > tracerNames = flowSol -> tracerNames ();
if ( m_flowTracerSelectionMode == FLOW_TR_INJECTORS || m_flowTracerSelectionMode == FLOW_TR_INJ_AND_PROD )
2017-01-12 11:13:33 +01:00
{
2017-08-31 16:22:50 +02:00
for ( const QString & tracerName : tracerNames )
2017-01-12 11:13:33 +01:00
{
2017-08-31 16:22:50 +02:00
RimFlowDiagSolution :: TracerStatusType status = flowSol -> tracerStatusInTimeStep ( tracerName , timeStep );
if ( status == RimFlowDiagSolution :: INJECTOR )
{
selTracerNames . insert ( tracerName . toStdString ());
}
2017-01-12 11:13:33 +01:00
}
}
2017-08-31 16:22:50 +02:00
if ( m_flowTracerSelectionMode == FLOW_TR_PRODUCERS || m_flowTracerSelectionMode == FLOW_TR_INJ_AND_PROD )
2017-01-12 11:13:33 +01:00
{
2017-08-31 16:22:50 +02:00
for ( const QString & tracerName : tracerNames )
2017-01-12 11:13:33 +01:00
{
2017-08-31 16:22:50 +02:00
RimFlowDiagSolution :: TracerStatusType status = flowSol -> tracerStatusInTimeStep ( tracerName , timeStep );
if ( status == RimFlowDiagSolution :: PRODUCER )
{
selTracerNames . insert ( tracerName . toStdString ());
}
2017-01-12 11:13:33 +01:00
}
}
}
}
2016-12-16 14:17:56 +01:00
2017-08-31 16:22:50 +02:00
return RigFlowDiagResultAddress ( m_resultVariable (). toStdString (), m_phaseSelection (), selTracerNames );
}
else
{
std :: set < std :: string > selTracerNames ;
for ( const QString & selectedTracerName : m_selectedSouringTracers ())
{
selTracerNames . insert ( selectedTracerName . toUtf8 (). constData ());
}
2017-09-05 12:03:17 +02:00
return RigFlowDiagResultAddress ( m_resultVariable (). toStdString (), RigFlowDiagResultAddress :: PHASE_ALL , selTracerNames );
2017-08-31 16:22:50 +02:00
}
2016-12-16 14:17:56 +01:00
}
2017-03-02 16:10:18 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: setFlowDiagTracerSelectionType ( FlowTracerSelectionType selectionType )
{
m_flowTracerSelectionMode = selectionType ;
}
2017-01-04 13:13:06 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-01-12 15:00:18 +01:00
QString RimEclipseResultDefinition :: resultVariableUiName () const
{
2017-06-13 15:41:52 +02:00
if ( resultType () == RiaDefines :: FLOW_DIAGNOSTICS )
2017-01-12 15:00:18 +01:00
{
2018-11-21 13:32:55 +01:00
return flowDiagResUiText ( false , 32 );
2017-01-12 15:00:18 +01:00
}
2019-01-30 16:46:16 +01:00
if ( m_isTimeLapseResult () && resultType () == RiaDefines :: DYNAMIC_NATIVE )
{
return m_resultVariable () + "_D" + QString :: number ( m_timeLapseBaseTimestep ());
}
else
{
return m_resultVariable ();
}
2017-01-12 15:00:18 +01:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimEclipseResultDefinition :: resultVariableUiShortName () const
2017-01-04 13:13:06 +01:00
{
2017-06-13 15:41:52 +02:00
if ( resultType () == RiaDefines :: FLOW_DIAGNOSTICS )
2017-01-04 13:13:06 +01:00
{
2018-11-21 13:32:55 +01:00
return flowDiagResUiText ( true , 24 );
2017-01-04 13:13:06 +01:00
}
2019-01-30 16:46:16 +01:00
if ( m_isTimeLapseResult () && resultType () == RiaDefines :: DYNAMIC_NATIVE )
{
return m_resultVariable () + "_D" + QString :: number ( m_timeLapseBaseTimestep ());
}
else
{
return m_resultVariable ();
}
2017-01-04 13:13:06 +01:00
}
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 09:38:53 +02:00
void RimEclipseResultDefinition :: loadResult ()
2012-05-18 09:45:23 +02:00
{
2017-10-18 11:31:19 +02:00
if ( isFlowDiagOrInjectionFlooding ()) return ; // Will load automatically on access
2016-12-20 14:33:35 +01:00
2019-01-29 10:01:24 +01:00
if ( m_eclipseCase )
{
if ( ! m_eclipseCase -> ensureReservoirCaseIsOpen ())
{
RiaLogging :: error ( "Could not open the Eclipse Grid file: " + m_eclipseCase -> gridFileName ());
return ;
}
}
2017-09-13 10:39:20 +02:00
RigCaseCellResultsData * gridCellResults = this -> currentGridCellResults ();
2012-05-18 09:45:23 +02:00
if ( gridCellResults )
{
2019-01-30 16:46:16 +01:00
if ( m_isTimeLapseResult ())
{
gridCellResults -> createResultEntry ( this -> eclipseResultAddress (), false );
}
gridCellResults -> ensureKnownResultLoaded ( this -> eclipseResultAddress ());
2012-05-18 09:45:23 +02:00
}
2014-08-01 12:55:43 +02:00
2012-05-18 09:45:23 +02:00
}
//--------------------------------------------------------------------------------------------------
2012-06-26 16:10:41 +02:00
/// Returns whether the result requested by the definition is a single frame result
/// The result needs to be loaded before asking
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
2015-06-25 09:38:53 +02:00
bool RimEclipseResultDefinition :: hasStaticResult () const
2012-05-18 09:45:23 +02:00
{
2017-10-18 11:31:19 +02:00
if ( isFlowDiagOrInjectionFlooding ()) return false ;
2016-12-16 14:53:56 +01:00
2017-09-13 10:39:20 +02:00
const RigCaseCellResultsData * gridCellResults = this -> currentGridCellResults ();
2019-01-23 14:24:12 +01:00
RigEclipseResultAddress gridScalarResultIndex = this -> eclipseResultAddress ();
2013-06-12 13:42:36 +02:00
2017-09-13 10:39:20 +02:00
if ( hasResult () && gridCellResults -> timeStepCount ( gridScalarResultIndex ) == 1 )
2012-05-18 09:45:23 +02:00
{
return true ;
}
else
{
return false ;
}
}
//--------------------------------------------------------------------------------------------------
2012-06-26 16:10:41 +02:00
/// Returns whether the result requested by the definition is loaded or possible to load from the result file
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
2015-06-25 09:38:53 +02:00
bool RimEclipseResultDefinition :: hasResult () const
2012-05-18 09:45:23 +02:00
{
2017-10-18 11:31:19 +02:00
if ( isFlowDiagOrInjectionFlooding ())
2016-12-16 14:53:56 +01:00
{
if ( m_flowSolution () && ! m_resultVariable (). isEmpty ()) return true ;
}
2017-09-13 10:39:20 +02:00
else if ( this -> currentGridCellResults () )
2012-05-18 09:45:23 +02:00
{
2017-09-13 10:39:20 +02:00
const RigCaseCellResultsData * gridCellResults = this -> currentGridCellResults ();
2019-01-28 16:18:28 +01:00
2019-01-30 16:46:16 +01:00
return gridCellResults -> hasResultEntry ( this -> eclipseResultAddress ());
2012-05-18 09:45:23 +02:00
}
return false ;
}
//--------------------------------------------------------------------------------------------------
2012-06-26 16:10:41 +02:00
/// Returns whether the result requested by the definition is a multi frame result
/// The result needs to be loaded before asking
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
2015-06-25 09:38:53 +02:00
bool RimEclipseResultDefinition :: hasDynamicResult () const
2012-05-18 09:45:23 +02:00
{
2013-04-10 14:55:50 +02:00
if ( hasResult ())
{
2017-06-13 15:41:52 +02:00
if ( m_resultType () == RiaDefines :: DYNAMIC_NATIVE )
2013-04-10 14:55:50 +02:00
{
return true ;
}
2017-08-14 10:47:44 +02:00
else if ( m_resultType () == RiaDefines :: SOURSIMRL )
2017-07-07 13:31:14 +02:00
{
return true ;
}
2017-06-13 15:41:52 +02:00
else if ( m_resultType () == RiaDefines :: FLOW_DIAGNOSTICS )
2016-12-16 14:53:56 +01:00
{
return true ;
}
2017-08-31 16:22:50 +02:00
else if ( m_resultType () == RiaDefines :: INJECTION_FLOODING )
{
return true ;
}
2013-04-10 14:55:50 +02:00
2017-09-13 10:39:20 +02:00
if ( this -> currentGridCellResults ())
2013-04-10 14:55:50 +02:00
{
2017-09-13 10:39:20 +02:00
const RigCaseCellResultsData * gridCellResults = this -> currentGridCellResults ();
2019-01-23 14:24:12 +01:00
RigEclipseResultAddress gridScalarResultIndex = this -> eclipseResultAddress ();
2013-06-12 13:42:36 +02:00
if ( gridCellResults -> timeStepCount ( gridScalarResultIndex ) > 1 )
2013-04-22 13:25:32 +02:00
{
return true ;
}
2013-04-10 14:55:50 +02:00
}
}
return false ;
2012-05-18 09:45:23 +02:00
}
2012-06-26 16:10:41 +02:00
2013-04-30 13:41:53 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 09:38:53 +02:00
void RimEclipseResultDefinition :: initAfterRead ()
2013-04-30 13:41:53 +02:00
{
2018-11-30 11:25:56 +01:00
if ( m_flowSolution () == nullptr )
{
assignFlowSolutionFromCase ();
}
2013-04-30 13:41:53 +02:00
m_porosityModelUiField = m_porosityModel ;
m_resultTypeUiField = m_resultType ;
m_resultVariableUiField = m_resultVariable ;
2019-01-30 16:46:16 +01:00
m_isTimeLapseResultUiField = m_isTimeLapseResult ;
m_timeLapseBaseTimestepUiField = m_timeLapseBaseTimestep ;
2014-08-01 13:35:52 +02:00
2016-12-14 09:50:30 +01:00
m_flowSolutionUiField = m_flowSolution ();
2018-09-27 15:11:49 +02:00
m_selectedInjectorTracersUiField = m_selectedInjectorTracers ;
2014-08-01 13:35:52 +02:00
this -> updateUiIconFromToggleField ();
2013-04-30 13:41:53 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-06-13 15:41:52 +02:00
void RimEclipseResultDefinition :: setResultType ( RiaDefines :: ResultCatType val )
2013-04-30 13:41:53 +02:00
{
m_resultType = val ;
m_resultTypeUiField = val ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-08-11 14:05:59 +02:00
void RimEclipseResultDefinition :: setPorosityModel ( RiaDefines :: PorosityModelType val )
2013-04-30 13:41:53 +02:00
{
m_porosityModel = val ;
m_porosityModelUiField = val ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 09:38:53 +02:00
void RimEclipseResultDefinition :: setResultVariable ( const QString & val )
2013-04-30 13:41:53 +02:00
{
m_resultVariable = val ;
m_resultVariableUiField = val ;
}
2016-12-16 14:17:56 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFlowDiagSolution * RimEclipseResultDefinition :: flowDiagSolution ()
{
return m_flowSolution ();
}
2016-12-20 14:33:35 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: setFlowSolution ( RimFlowDiagSolution * flowSol )
{
this -> m_flowSolution = flowSol ;
this -> m_flowSolutionUiField = flowSol ;
}
//--------------------------------------------------------------------------------------------------
2018-09-27 15:11:49 +02:00
///
2016-12-20 14:33:35 +01:00
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: setSelectedTracers ( const std :: vector < QString >& selectedTracers )
{
2018-09-27 15:11:49 +02:00
if ( m_flowSolution () == nullptr )
{
assignFlowSolutionFromCase ();
}
if ( m_flowSolution ())
{
std :: vector < QString > injectorTracers ;
std :: vector < QString > producerTracers ;
for ( const QString & tracerName : selectedTracers )
{
RimFlowDiagSolution :: TracerStatusType tracerStatus = m_flowSolution () -> tracerStatusOverall ( tracerName );
if ( tracerStatus == RimFlowDiagSolution :: INJECTOR )
{
injectorTracers . push_back ( tracerName );
}
else if ( tracerStatus == RimFlowDiagSolution :: PRODUCER )
{
producerTracers . push_back ( tracerName );
}
else if ( tracerStatus == RimFlowDiagSolution :: VARYING || tracerStatus == RimFlowDiagSolution :: UNDEFINED )
{
injectorTracers . push_back ( tracerName );
producerTracers . push_back ( tracerName );
}
}
setSelectedInjectorTracers ( injectorTracers );
setSelectedProducerTracers ( producerTracers );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: setSelectedInjectorTracers ( const std :: vector < QString >& selectedTracers )
{
this -> m_selectedInjectorTracers = selectedTracers ;
this -> m_selectedInjectorTracersUiField = selectedTracers ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: setSelectedProducerTracers ( const std :: vector < QString >& selectedTracers )
{
this -> m_selectedProducerTracers = selectedTracers ;
this -> m_selectedProducerTracersUiField = selectedTracers ;
2016-12-20 14:33:35 +01:00
}
2017-08-31 16:22:50 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: setSelectedSouringTracers ( const std :: vector < QString >& selectedTracers )
{
this -> m_selectedSouringTracers = selectedTracers ;
this -> m_selectedSouringTracersUiField = selectedTracers ;
}
2018-02-13 13:29:44 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: updateUiFieldsFromActiveResult ()
{
m_resultTypeUiField = m_resultType ;
m_resultVariableUiField = resultVariable ();
}
2013-04-30 13:41:53 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 09:38:53 +02:00
bool RimEclipseResultDefinition :: isTernarySaturationSelected () const
2013-04-30 13:41:53 +02:00
{
2017-06-13 15:41:52 +02:00
bool isTernary = ( m_resultType () == RiaDefines :: DYNAMIC_NATIVE ) &&
( m_resultVariable (). compare ( RiaDefines :: ternarySaturationResultName (), Qt :: CaseInsensitive ) == 0 );
2014-08-01 12:55:43 +02:00
return isTernary ;
2013-04-30 13:41:53 +02:00
}
2014-04-04 10:59:21 +02:00
2017-06-01 13:46:22 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipseResultDefinition :: isCompletionTypeSelected () const
{
2017-06-13 15:41:52 +02:00
return ( m_resultType () == RiaDefines :: DYNAMIC_NATIVE && m_resultVariable () == RiaDefines :: completionTypeResultName ());
2017-06-01 13:46:22 +02:00
}
2016-08-05 08:31:15 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipseResultDefinition :: hasCategoryResult () const
{
2017-06-13 15:41:52 +02:00
if ( this -> m_resultType () == RiaDefines :: FORMATION_NAMES
2016-09-06 10:27:30 +02:00
&& m_eclipseCase
2017-03-15 09:10:16 +01:00
&& m_eclipseCase -> eclipseCaseData ()
&& m_eclipseCase -> eclipseCaseData () -> activeFormationNames () ) return true ;
2016-09-06 10:27:30 +02:00
2017-06-13 15:41:52 +02:00
if ( this -> m_resultType () == RiaDefines :: DYNAMIC_NATIVE
&& this -> resultVariable () == RiaDefines :: completionTypeResultName ()) return true ;
2017-05-31 16:16:28 +02:00
2017-06-13 15:41:52 +02:00
if ( this -> m_resultType () == RiaDefines :: FLOW_DIAGNOSTICS
2016-12-20 14:33:35 +01:00
&& m_resultVariable () == RIG_FLD_MAX_FRACTION_TRACER_RESNAME ) return true ;
2016-08-05 08:31:15 +02:00
if ( ! this -> hasStaticResult ()) return false ;
return this -> resultVariable (). contains ( "NUM" , Qt :: CaseInsensitive );
}
2017-10-18 11:31:19 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipseResultDefinition :: isFlowDiagOrInjectionFlooding () const
{
if ( this -> m_resultType () == RiaDefines :: FLOW_DIAGNOSTICS || this -> m_resultType () == RiaDefines :: INJECTION_FLOODING )
{
return true ;
}
return false ;
}
2016-12-14 09:50:30 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: defineUiOrdering ( QString uiConfigName , caf :: PdmUiOrdering & uiOrdering )
{
uiOrdering . add ( & m_resultTypeUiField );
2017-01-12 11:13:33 +01:00
2016-12-14 09:50:30 +01:00
if ( hasDualPorFractureResult ())
{
uiOrdering . add ( & m_porosityModelUiField );
}
2017-01-12 11:13:33 +01:00
2019-01-30 16:46:16 +01:00
2017-06-13 15:41:52 +02:00
if ( m_resultTypeUiField () == RiaDefines :: FLOW_DIAGNOSTICS )
2016-12-14 09:50:30 +01:00
{
uiOrdering . add ( & m_flowSolutionUiField );
2017-01-12 11:13:33 +01:00
uiOrdering . add ( & m_flowTracerSelectionMode );
2017-01-12 15:00:18 +01:00
if ( m_flowTracerSelectionMode == FLOW_TR_BY_SELECTION )
2017-01-12 11:13:33 +01:00
{
2018-09-27 15:11:49 +02:00
caf :: PdmUiGroup * selectionGroup = uiOrdering . addNewGroup ( "Tracer Selection" );
selectionGroup -> setEnableFrame ( false );
2018-09-28 14:21:55 +02:00
2018-09-27 15:11:49 +02:00
caf :: PdmUiGroup * injectorGroup = selectionGroup -> addNewGroup ( "Injectors" );
injectorGroup -> add ( & m_selectedInjectorTracersUiField );
2018-09-28 13:21:02 +02:00
injectorGroup -> add ( & m_syncInjectorToProducerSelection );
2018-09-28 14:21:55 +02:00
2018-09-27 15:11:49 +02:00
caf :: PdmUiGroup * producerGroup = selectionGroup -> addNewGroup ( "Producers" , false );
producerGroup -> add ( & m_selectedProducerTracersUiField );
2018-09-28 13:21:02 +02:00
producerGroup -> add ( & m_syncProducerToInjectorSelection );
2017-01-12 11:13:33 +01:00
}
2016-12-20 14:33:35 +01:00
2017-08-10 15:08:30 +02:00
uiOrdering . add ( & m_phaseSelection );
2016-12-20 14:33:35 +01:00
if ( m_flowSolution () == nullptr )
{
2017-02-13 15:00:49 +01:00
assignFlowSolutionFromCase ();
2016-12-20 14:33:35 +01:00
}
2016-12-14 09:50:30 +01:00
}
2017-08-31 16:22:50 +02:00
if ( m_resultTypeUiField () == RiaDefines :: INJECTION_FLOODING )
{
uiOrdering . add ( & m_selectedSouringTracersUiField );
}
2018-09-27 22:29:04 +02:00
if ( m_resultTypeUiField () == RiaDefines :: FLOW_DIAGNOSTICS )
{
2018-09-28 09:39:29 +02:00
uiOrdering . add ( & m_resultVariableUiField );
2018-09-27 22:29:04 +02:00
}
else
{
uiOrdering . add ( & m_resultVariableUiField );
}
2016-12-14 09:50:30 +01:00
2019-01-30 16:46:16 +01:00
if ( m_resultTypeUiField () == RiaDefines :: DYNAMIC_NATIVE )
{
caf :: PdmUiGroup * timeLapseGr = uiOrdering . addNewGroup ( "Relative Result Options" );
timeLapseGr -> add ( & m_isTimeLapseResultUiField );
if ( m_isTimeLapseResultUiField () )
timeLapseGr -> add ( & m_timeLapseBaseTimestepUiField );
}
2017-03-21 13:47:53 +01:00
uiOrdering . skipRemainingFields ( true );
2014-04-04 10:59:21 +02:00
}
2014-09-08 07:53:49 +02:00
2017-03-27 22:54:13 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: defineEditorAttribute ( const caf :: PdmFieldHandle * field , QString uiConfigName , caf :: PdmUiEditorAttribute * attribute )
{
2018-09-28 13:21:02 +02:00
if ( m_resultTypeUiField () == RiaDefines :: FLOW_DIAGNOSTICS )
2017-03-27 22:54:13 +02:00
{
2018-09-28 13:21:02 +02:00
if ( field == & m_resultVariableUiField )
2017-03-27 22:54:13 +02:00
{
2018-09-28 13:21:02 +02:00
caf :: PdmUiListEditorAttribute * listEditAttr = dynamic_cast < caf :: PdmUiListEditorAttribute *> ( attribute );
if ( listEditAttr )
{
listEditAttr -> m_heightHint = 50 ;
}
}
else if ( field == & m_syncInjectorToProducerSelection ||
field == & m_syncProducerToInjectorSelection )
{
caf :: PdmUiToolButtonEditorAttribute * toolButtonAttr = dynamic_cast < caf :: PdmUiToolButtonEditorAttribute *> ( attribute );
if ( toolButtonAttr )
{
toolButtonAttr -> m_sizePolicy . setHorizontalPolicy ( QSizePolicy :: MinimumExpanding );
}
}
}
}
2018-11-30 11:25:56 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: onEditorWidgetsCreated ()
{
if ( m_flowSolution () && ! m_selectedTracers_OBSOLETE (). empty ())
{
std :: vector < QString > selectedTracers ;
selectedTracers . swap ( m_selectedTracers_OBSOLETE . v ());
std :: set < QString , TracerComp > allInjectorTracers = setOfTracersOfType ( true );
std :: set < QString , TracerComp > allProducerTracers = setOfTracersOfType ( false );
std :: vector < QString > selectedInjectorTracers ;
std :: vector < QString > selectedProducerTracers ;
for ( const QString & tracerName : selectedTracers )
{
if ( allInjectorTracers . count ( tracerName ))
{
selectedInjectorTracers . push_back ( tracerName );
}
if ( allProducerTracers . count ( tracerName ))
{
selectedProducerTracers . push_back ( tracerName );
}
}
if ( ! selectedInjectorTracers . empty ())
{
setSelectedInjectorTracers ( selectedInjectorTracers );
}
if ( ! selectedProducerTracers . empty ())
{
setSelectedProducerTracers ( selectedProducerTracers );
}
}
}
2018-09-28 13:21:02 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipseResultDefinition :: TracerComp :: operator ()( const QString & lhs , const QString & rhs ) const
{
if ( ! lhs . endsWith ( "-XF" ) && rhs . endsWith ( "-XF" ))
{
return true ;
}
else if ( lhs . endsWith ( "-XF" ) && ! rhs . endsWith ( "-XF" ))
{
return false ;
}
else
{
return lhs < rhs ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: assignFlowSolutionFromCase ()
{
RimFlowDiagSolution * defaultFlowDiagSolution = nullptr ;
RimEclipseResultCase * eclCase = dynamic_cast < RimEclipseResultCase *> ( m_eclipseCase . p ());
if ( eclCase )
{
defaultFlowDiagSolution = eclCase -> defaultFlowDiagSolution ();
}
this -> setFlowSolution ( defaultFlowDiagSolution );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipseResultDefinition :: hasDualPorFractureResult ()
{
if ( m_eclipseCase
&& m_eclipseCase -> eclipseCaseData ())
{
return m_eclipseCase -> eclipseCaseData () -> hasFractureResults ();
}
return false ;
}
2018-11-21 13:32:55 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimEclipseResultDefinition :: flowDiagResUiText ( bool shortLabel , int maxTracerStringLength ) const
{
QString uiText = QString :: fromStdString ( flowDiagResAddress (). variableName );
if ( flowDiagResAddress (). variableName == RIG_FLD_TOF_RESNAME )
{
uiText = timeOfFlightString ( shortLabel );
}
else if ( flowDiagResAddress (). variableName == RIG_FLD_MAX_FRACTION_TRACER_RESNAME )
{
uiText = maxFractionTracerString ( shortLabel );
}
QString tracersString = selectedTracersString ();
if ( ! tracersString . isEmpty ())
{
const QString postfix = "..." ;
if ( tracersString . size () > maxTracerStringLength + postfix . size ())
{
tracersString = tracersString . left ( maxTracerStringLength );
tracersString += postfix ;
}
uiText += QString ( " \n %1" ). arg ( tracersString );
}
return uiText ;
}
2019-01-30 16:46:16 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimEclipseResultDefinition :: convertToTimeDiffUiVarName ( const QString & resultName )
{
if ( m_isTimeLapseResultUiField () && m_resultTypeUiField () == RiaDefines :: DYNAMIC_NATIVE )
{
return resultName + "_D" + QString :: number ( m_timeLapseBaseTimestepUiField ());
}
else
{
return resultName ;
}
}
2018-09-28 14:21:55 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-09-28 13:21:02 +02:00
QList < caf :: PdmOptionItemInfo > RimEclipseResultDefinition :: calcOptionsForVariableUiFieldStandard ()
{
CVF_ASSERT ( m_resultTypeUiField () != RiaDefines :: FLOW_DIAGNOSTICS && m_resultTypeUiField () != RiaDefines :: INJECTION_FLOODING );
if ( this -> currentGridCellResults ())
{
QList < caf :: PdmOptionItemInfo > optionList ;
QStringList cellCenterResultNames ;
QStringList cellFaceResultNames ;
RigCaseCellResultsData * results = this -> currentGridCellResults ();
2019-01-30 16:46:16 +01:00
2018-09-28 13:21:02 +02:00
foreach ( QString s , getResultNamesForCurrentUiResultType ())
{
if ( s == RiaDefines :: completionTypeResultName () && results -> timeStepDates (). empty ()) continue ;
if ( RiaDefines :: isPerCellFaceResult ( s ))
{
cellFaceResultNames . push_back ( s );
}
else
{
cellCenterResultNames . push_back ( s );
}
}
cellCenterResultNames . sort ();
cellFaceResultNames . sort ();
// Cell Center result names
foreach ( QString s , cellCenterResultNames )
{
2019-01-30 16:46:16 +01:00
optionList . push_back ( caf :: PdmOptionItemInfo ( convertToTimeDiffUiVarName ( s ), s ));
2018-09-28 13:21:02 +02:00
}
// Ternary Result
bool hasAtLeastOneTernaryComponent = false ;
2018-09-28 14:21:55 +02:00
if ( cellCenterResultNames . contains ( "SOIL" )) hasAtLeastOneTernaryComponent = true ;
else if ( cellCenterResultNames . contains ( "SGAS" )) hasAtLeastOneTernaryComponent = true ;
else if ( cellCenterResultNames . contains ( "SWAT" )) hasAtLeastOneTernaryComponent = true ;
2018-09-28 13:21:02 +02:00
if ( m_resultTypeUiField == RiaDefines :: DYNAMIC_NATIVE && hasAtLeastOneTernaryComponent )
{
2018-09-28 14:21:55 +02:00
optionList . push_front ( caf :: PdmOptionItemInfo ( RiaDefines :: ternarySaturationResultName (), RiaDefines :: ternarySaturationResultName ()));
2018-09-28 13:21:02 +02:00
}
// Cell Face result names
bool showDerivedResultsFirstInList = false ;
{
RimEclipseFaultColors * rimEclipseFaultColors = nullptr ;
this -> firstAncestorOrThisOfType ( rimEclipseFaultColors );
2018-09-28 14:21:55 +02:00
if ( rimEclipseFaultColors ) showDerivedResultsFirstInList = true ;
2018-09-28 13:21:02 +02:00
}
foreach ( QString s , cellFaceResultNames )
{
if ( showDerivedResultsFirstInList )
{
2019-01-30 16:46:16 +01:00
optionList . push_front ( caf :: PdmOptionItemInfo ( convertToTimeDiffUiVarName ( s ), s ));
2018-09-28 13:21:02 +02:00
}
else
{
2019-01-30 16:46:16 +01:00
optionList . push_back ( caf :: PdmOptionItemInfo ( convertToTimeDiffUiVarName ( s ), s ));
2018-09-28 13:21:02 +02:00
}
}
optionList . push_front ( caf :: PdmOptionItemInfo ( RiaDefines :: undefinedResultName (), RiaDefines :: undefinedResultName ()));
// Remove Per Cell Face options
{
RimPlotCurve * curve = nullptr ;
this -> firstAncestorOrThisOfType ( curve );
RimEclipsePropertyFilter * propFilter = nullptr ;
this -> firstAncestorOrThisOfType ( propFilter );
RimCellEdgeColors * cellEdge = nullptr ;
this -> firstAncestorOrThisOfType ( cellEdge );
2018-09-28 14:21:55 +02:00
if ( propFilter || curve || cellEdge )
2018-09-28 13:21:02 +02:00
{
removePerCellFaceOptionItems ( optionList );
}
}
return optionList ;
}
return QList < caf :: PdmOptionItemInfo > ();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList < caf :: PdmOptionItemInfo > RimEclipseResultDefinition :: calcOptionsForSelectedTracerField ( bool injector )
{
QList < caf :: PdmOptionItemInfo > options ;
RimFlowDiagSolution * flowSol = m_flowSolutionUiField ();
if ( flowSol )
{
std :: set < QString , TracerComp > sortedTracers = setOfTracersOfType ( injector );
for ( const QString & tracerName : sortedTracers )
{
QString postfix ;
RimFlowDiagSolution :: TracerStatusType status = flowSol -> tracerStatusOverall ( tracerName );
if ( status == RimFlowDiagSolution :: VARYING )
{
postfix = " [I/P]" ;
}
else if ( status == RimFlowDiagSolution :: UNDEFINED )
{
postfix = " [U]" ;
}
options . push_back ( caf :: PdmOptionItemInfo ( tracerName + postfix , tracerName ));
}
}
return options ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-11-21 13:32:55 +01:00
QString RimEclipseResultDefinition :: timeOfFlightString ( bool shorter ) const
2018-09-28 13:21:02 +02:00
{
2018-11-21 13:32:55 +01:00
QString tofString ;
bool multipleSelected = false ;
2018-09-28 14:21:55 +02:00
if ( injectorSelectionState () != NONE_SELECTED && producerSelectionState () != NONE_SELECTED )
2018-09-28 13:21:02 +02:00
{
2018-11-21 13:32:55 +01:00
tofString = shorter ? "Res.Time" : "Residence Time" ;
multipleSelected = true ;
2018-09-28 13:21:02 +02:00
}
2018-11-21 13:32:55 +01:00
else if ( injectorSelectionState () != NONE_SELECTED )
2018-09-28 13:21:02 +02:00
{
2018-11-21 13:32:55 +01:00
tofString = shorter ? "Fwd.TOF" : "Forward Time Of Flight" ;
2018-09-28 13:21:02 +02:00
}
2018-11-21 13:32:55 +01:00
else if ( producerSelectionState () != NONE_SELECTED )
2018-09-28 13:21:02 +02:00
{
2018-11-21 13:32:55 +01:00
tofString = shorter ? "Rev.TOF" : "Reverse Time Of Flight" ;
2018-09-28 13:21:02 +02:00
}
2018-11-21 13:32:55 +01:00
else
2018-09-28 13:21:02 +02:00
{
2018-11-21 13:32:55 +01:00
tofString = shorter ? "TOF" : "Time Of Flight" ;
2018-09-28 13:21:02 +02:00
}
2018-11-21 13:32:55 +01:00
multipleSelected = multipleSelected ||
injectorSelectionState () >= MULTIPLE_SELECTED || producerSelectionState () >= MULTIPLE_SELECTED ;
if ( multipleSelected && ! shorter )
2018-09-28 13:21:02 +02:00
{
2018-11-21 13:32:55 +01:00
tofString += " (Average)" ;
2018-09-28 13:21:02 +02:00
}
2018-11-21 13:32:55 +01:00
return tofString ;
2018-09-28 13:21:02 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-11-21 13:32:55 +01:00
QString RimEclipseResultDefinition :: maxFractionTracerString ( bool shorter ) const
2018-09-28 13:21:02 +02:00
{
2018-11-21 13:32:55 +01:00
QString mfString ;
if ( injectorSelectionState () >= ONE_SELECTED && producerSelectionState () == NONE_SELECTED )
2018-09-28 13:21:02 +02:00
{
2018-11-21 13:32:55 +01:00
mfString = shorter ? "FloodReg" : "Flooding Region" ;
if ( injectorSelectionState () >= MULTIPLE_SELECTED )
mfString += "s" ;
2018-09-28 13:21:02 +02:00
}
2018-11-21 13:32:55 +01:00
else if ( injectorSelectionState () == NONE_SELECTED && producerSelectionState () >= ONE_SELECTED )
{
mfString = shorter ? "DrainReg" : "Drainage Region" ;
if ( producerSelectionState () >= MULTIPLE_SELECTED )
mfString += "s" ;
}
else
{
mfString = shorter ? "Drain&FloodReg" : "Drainage/Flooding Regions" ;
}
return mfString ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimEclipseResultDefinition :: selectedTracersString () const
{
QStringList fullTracersList ;
FlowTracerSelectionState injectorState = injectorSelectionState ();
FlowTracerSelectionState producerState = producerSelectionState ();
if ( injectorState == ALL_SELECTED && producerState == ALL_SELECTED )
2018-09-28 13:21:02 +02:00
{
2018-11-21 13:32:55 +01:00
fullTracersList += caf :: AppEnum < FlowTracerSelectionType >:: uiText ( FLOW_TR_INJ_AND_PROD );
2018-09-28 13:21:02 +02:00
}
2018-11-21 13:32:55 +01:00
else
2018-09-28 13:21:02 +02:00
{
2018-11-21 13:32:55 +01:00
if ( injectorState == ALL_SELECTED )
{
fullTracersList += caf :: AppEnum < FlowTracerSelectionType >:: uiText ( FLOW_TR_INJECTORS );
}
if ( producerState == ALL_SELECTED )
{
fullTracersList += caf :: AppEnum < FlowTracerSelectionType >:: uiText ( FLOW_TR_PRODUCERS );
}
if ( injectorSelectionState () == ONE_SELECTED || injectorSelectionState () == MULTIPLE_SELECTED )
{
QStringList listOfSelectedInjectors ;
for ( const QString & injector : m_selectedInjectorTracers ())
{
listOfSelectedInjectors . push_back ( injector );
}
if ( ! listOfSelectedInjectors . empty ())
{
fullTracersList += listOfSelectedInjectors . join ( ", " );
}
}
if ( producerSelectionState () == ONE_SELECTED || producerSelectionState () == MULTIPLE_SELECTED )
{
QStringList listOfSelectedProducers ;
for ( const QString & producer : m_selectedProducerTracers ())
{
listOfSelectedProducers . push_back ( producer );
}
if ( ! listOfSelectedProducers . empty ())
{
fullTracersList . push_back ( listOfSelectedProducers . join ( ", " ));
}
}
2018-09-28 13:21:02 +02:00
}
2018-11-21 13:32:55 +01:00
QString tracersText ;
if ( ! fullTracersList . empty ())
2018-09-28 13:21:02 +02:00
{
2018-11-21 13:32:55 +01:00
tracersText = fullTracersList . join ( ", " );
2018-09-28 13:21:02 +02:00
}
2018-11-21 13:32:55 +01:00
return tracersText ;
2018-09-28 13:21:02 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RimEclipseResultDefinition :: getResultNamesForCurrentUiResultType ()
{
if ( m_resultTypeUiField () != RiaDefines :: FLOW_DIAGNOSTICS )
{
RigCaseCellResultsData * cellResultsStorage = currentGridCellResults ();
if ( ! cellResultsStorage ) return QStringList ();
return cellResultsStorage -> resultNames ( m_resultTypeUiField ());
}
else
{
QStringList flowVars ;
flowVars . push_back ( RIG_FLD_TOF_RESNAME );
flowVars . push_back ( RIG_FLD_CELL_FRACTION_RESNAME );
flowVars . push_back ( RIG_FLD_MAX_FRACTION_TRACER_RESNAME );
flowVars . push_back ( RIG_FLD_COMMUNICATION_RESNAME );
return flowVars ;
2017-03-27 22:54:13 +02:00
}
}
2015-09-21 11:43:22 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: removePerCellFaceOptionItems ( QList < caf :: PdmOptionItemInfo >& optionItems )
{
std :: vector < int > indicesToRemove ;
for ( int i = 0 ; i < optionItems . size (); i ++ )
{
2019-01-30 16:46:16 +01:00
QString text = optionItems [ i ]. value (). toString ();
2015-09-21 11:43:22 +02:00
2017-06-13 15:41:52 +02:00
if ( RiaDefines :: isPerCellFaceResult ( text ))
2015-09-21 11:43:22 +02:00
{
indicesToRemove . push_back ( i );
}
}
std :: sort ( indicesToRemove . begin (), indicesToRemove . end ());
std :: vector < int >:: reverse_iterator rit ;
for ( rit = indicesToRemove . rbegin (); rit != indicesToRemove . rend (); ++ rit )
{
optionItems . takeAt ( * rit );
}
}
2017-03-27 11:24:51 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-09-28 09:39:29 +02:00
std :: vector < QString > RimEclipseResultDefinition :: allTracerNames () const
2017-03-27 11:24:51 +02:00
{
2018-09-28 09:39:29 +02:00
std :: vector < QString > tracerNames ;
2017-03-27 11:24:51 +02:00
RimFlowDiagSolution * flowSol = m_flowSolutionUiField ();
if ( flowSol )
{
2018-09-28 09:39:29 +02:00
tracerNames = flowSol -> tracerNames ();
2017-03-27 11:24:51 +02:00
}
2018-09-28 09:39:29 +02:00
return tracerNames ;
2018-09-27 15:11:49 +02:00
}
2018-09-27 22:29:04 +02:00
2018-09-28 13:21:02 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std :: set < QString , RimEclipseResultDefinition :: TracerComp > RimEclipseResultDefinition :: setOfTracersOfType ( bool injector ) const
{
std :: set < QString , TracerComp > sortedTracers ;
RimFlowDiagSolution * flowSol = m_flowSolutionUiField ();
if ( flowSol )
{
std :: vector < QString > tracerNames = allTracerNames ();
for ( const QString & tracerName : tracerNames )
{
RimFlowDiagSolution :: TracerStatusType status = flowSol -> tracerStatusOverall ( tracerName );
bool includeTracer = status == RimFlowDiagSolution :: VARYING || status == RimFlowDiagSolution :: UNDEFINED ;
includeTracer |= injector && status == RimFlowDiagSolution :: INJECTOR ;
includeTracer |= ! injector && status == RimFlowDiagSolution :: PRODUCER ;
if ( includeTracer )
{
sortedTracers . insert ( tracerName );
}
}
}
return sortedTracers ;
}
2018-09-27 22:29:04 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-09-28 14:21:55 +02:00
RimEclipseResultDefinition :: FlowTracerSelectionState RimEclipseResultDefinition :: injectorSelectionState () const
2018-09-27 22:29:04 +02:00
{
if ( m_flowTracerSelectionMode == FLOW_TR_INJECTORS || m_flowTracerSelectionMode == FLOW_TR_INJ_AND_PROD )
{
2018-09-28 14:21:55 +02:00
return ALL_SELECTED ;
2018-09-27 22:29:04 +02:00
}
else if ( m_flowTracerSelectionMode == FLOW_TR_BY_SELECTION )
{
2018-09-28 14:21:55 +02:00
if ( m_selectedInjectorTracers (). size () == setOfTracersOfType ( true ). size ())
{
return ALL_SELECTED ;
}
else if ( m_selectedInjectorTracers (). size () == ( size_t ) 1 )
2018-09-27 22:29:04 +02:00
{
return ONE_SELECTED ;
}
2018-09-28 09:39:29 +02:00
else if ( m_selectedInjectorTracers (). size () > ( size_t ) 1 )
2018-09-27 22:29:04 +02:00
{
return MULTIPLE_SELECTED ;
}
}
return NONE_SELECTED ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-09-28 14:21:55 +02:00
RimEclipseResultDefinition :: FlowTracerSelectionState RimEclipseResultDefinition :: producerSelectionState () const
2018-09-27 22:29:04 +02:00
{
if ( m_flowTracerSelectionMode == FLOW_TR_PRODUCERS || m_flowTracerSelectionMode == FLOW_TR_INJ_AND_PROD )
{
2018-09-28 14:21:55 +02:00
return ALL_SELECTED ;
2018-09-27 22:29:04 +02:00
}
else if ( m_flowTracerSelectionMode == FLOW_TR_BY_SELECTION )
{
2018-09-28 14:21:55 +02:00
if ( m_selectedProducerTracers (). size () == setOfTracersOfType ( false ). size ())
{
return ALL_SELECTED ;
}
else if ( m_selectedProducerTracers (). size () == ( size_t ) 1 )
2018-09-27 22:29:04 +02:00
{
return ONE_SELECTED ;
}
2018-09-28 09:39:29 +02:00
else if ( m_selectedProducerTracers (). size () > ( size_t ) 1 )
2018-09-27 22:29:04 +02:00
{
return MULTIPLE_SELECTED ;
}
}
return NONE_SELECTED ;
}
2018-09-28 13:21:02 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: syncInjectorToProducerSelection ()
{
const double epsilon = 1.0e-8 ;
int timeStep = 0 ;
Rim3dView * rimView = nullptr ;
this -> firstAncestorOrThisOfType ( rimView );
if ( rimView )
{
timeStep = rimView -> currentTimeStep ();
}
RimFlowDiagSolution * flowSol = m_flowSolution ();
if ( flowSol && m_flowTracerSelectionMode == FLOW_TR_BY_SELECTION )
{
std :: set < QString , TracerComp > producers = setOfTracersOfType ( false );
std :: set < QString , TracerComp > newProducerSelection ;
for ( const QString & selectedInjector : m_selectedInjectorTracers ())
{
for ( const QString & producer : producers )
{
std :: pair < double , double > commFluxes = flowSol -> flowDiagResults () -> injectorProducerPairFluxes (
selectedInjector . toStdString (), producer . toStdString (), timeStep );
if ( std :: abs ( commFluxes . first ) > epsilon || std :: abs ( commFluxes . second ) > epsilon )
{
newProducerSelection . insert ( producer );
}
}
}
// Add all currently selected producers to set
for ( const QString & selectedProducer : m_selectedProducerTracers ())
{
newProducerSelection . insert ( selectedProducer );
}
std :: vector < QString > newProducerVector ( newProducerSelection . begin (), newProducerSelection . end ());
setSelectedProducerTracers ( newProducerVector );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition :: syncProducerToInjectorSelection ()
{
const double epsilon = 1.0e-8 ;
int timeStep = 0 ;
Rim3dView * rimView = nullptr ;
this -> firstAncestorOrThisOfType ( rimView );
if ( rimView )
{
timeStep = rimView -> currentTimeStep ();
}
RimFlowDiagSolution * flowSol = m_flowSolution ();
if ( flowSol && m_flowTracerSelectionMode == FLOW_TR_BY_SELECTION )
{
std :: set < QString , TracerComp > injectors = setOfTracersOfType ( true );
std :: set < QString , TracerComp > newInjectorSelection ;
for ( const QString & selectedProducer : m_selectedProducerTracers ())
{
for ( const QString & injector : injectors )
{
std :: pair < double , double > commFluxes = flowSol -> flowDiagResults () -> injectorProducerPairFluxes (
injector . toStdString (), selectedProducer . toStdString (), timeStep );
if ( std :: abs ( commFluxes . first ) > epsilon || std :: abs ( commFluxes . second ) > epsilon )
{
newInjectorSelection . insert ( injector );
}
}
}
// Add all currently selected injectors to set
for ( const QString & selectedInjector : m_selectedInjectorTracers ())
{
newInjectorSelection . insert ( selectedInjector );
}
std :: vector < QString > newInjectorVector ( newInjectorSelection . begin (), newInjectorSelection . end ());
setSelectedInjectorTracers ( newInjectorVector );
}
}