From 5f6468898bd4f8f8a03753766cb247aeb88abf87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 3 Jan 2017 13:14:07 +0100 Subject: [PATCH] #1052 3D info box: Added Flow Diag results statistics etc. --- .../Rim3dOverlayInfoConfig.cpp | 84 ++++++++++++++++++- .../ProjectDataModel/Rim3dOverlayInfoConfig.h | 3 + .../ReservoirDataModel/CMakeLists_files.cmake | 1 + .../RigFlowDiagResultAddress.cpp | 47 +++++++++++ .../RigFlowDiagResultAddress.h | 3 +- .../ReservoirDataModel/RigFlowDiagResults.cpp | 3 + 6 files changed, 136 insertions(+), 5 deletions(-) create mode 100644 ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.cpp diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 5685f9e142..d4021d87f2 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -45,6 +45,8 @@ #include "RimView.h" #include "RiuViewer.h" +#include "RigFlowDiagResults.h" +#include "RigFlowDiagVisibleCellsStatCalc.h" CAF_PDM_SOURCE_INIT(Rim3dOverlayInfoConfig, "View3dOverlayInfoConfig"); //-------------------------------------------------------------------------------------------------- @@ -182,6 +184,31 @@ caf::PdmFieldHandle* Rim3dOverlayInfoConfig::objectToggleField() return &active; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dOverlayInfoConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* visGroup = uiOrdering.addNewGroup("Visibility"); + + visGroup->add(&showAnimProgress); + visGroup->add(&showCaseInfo); + visGroup->add(&showResultInfo); + visGroup->add(&showHistogram); + + caf::PdmUiGroup* statGroup = uiOrdering.addNewGroup("Statistics Options"); + RimEclipseView * eclipseView = dynamic_cast(m_viewDef.p()); + + if ( !eclipseView || eclipseView->cellResult()->resultType() != RimDefines::FLOW_DIAGNOSTICS ) // + { + statGroup->add(&m_statisticsTimeRange); + } + statGroup->add(&m_statisticsCellRange); + + uiOrdering.setForgetRemainingFields(true); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -260,6 +287,36 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * eclipseView) } } } + else if (eclipseView->cellResult()->resultType() == RimDefines::FLOW_DIAGNOSTICS) + { + if ( m_statisticsTimeRange == CURRENT_TIMESTEP || m_statisticsTimeRange == ALL_TIMESTEPS) // All timesteps is ignored + { + int currentTimeStep = eclipseView->currentTimeStep(); + + if ( m_statisticsCellRange == ALL_CELLS ) + { + RigFlowDiagResults* fldResults = eclipseView->cellResult()->flowDiagSolution()->flowDiagResults(); + RigFlowDiagResultAddress resAddr = eclipseView->cellResult()->flowDiagResAddress(); + + fldResults->minMaxScalarValues(resAddr, currentTimeStep, &min, &max); + fldResults->p10p90ScalarValues(resAddr, currentTimeStep, &p10, &p90); + fldResults->meanScalarValue(resAddr, currentTimeStep, &mean); + fldResults->sumScalarValue(resAddr, currentTimeStep, &sum); + histogram = &(fldResults->scalarValuesHistogram(resAddr, currentTimeStep)); + } + else if (m_statisticsCellRange == VISIBLE_CELLS ) + { + updateVisCellStatsIfNeeded(); + + m_visibleCellStatistics->meanCellScalarValues(currentTimeStep, mean); + m_visibleCellStatistics->minMaxCellScalarValues(currentTimeStep, min, max); + m_visibleCellStatistics->p10p90CellScalarValues(currentTimeStep, p10, p90); + m_visibleCellStatistics->sumCellScalarValues(currentTimeStep, sum); + + histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram(currentTimeStep)); + } + } + } } } @@ -310,8 +367,15 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * eclipseView) if (isResultsInfoRelevant) { QString propName = eclipseView->cellResult()->resultVariable(); + QString timeRangeText = m_statisticsTimeRange().uiText(); + if ( eclipseView->cellResult()->resultType() == RimDefines::FLOW_DIAGNOSTICS ) + { + timeRangeText = caf::AppEnum::uiText(CURRENT_TIMESTEP); + propName = QString::fromStdString( eclipseView->cellResult()->flowDiagResAddress().uiText()); + } + infoText += QString("Cell Property: %1 ").arg(propName); - infoText += QString("
Statistics: ") + m_statisticsTimeRange().uiText() + " and " + m_statisticsCellRange().uiText(); + infoText += QString("
Statistics: ") + timeRangeText + " and " + m_statisticsCellRange().uiText(); infoText += QString("" "" "" @@ -550,10 +614,22 @@ void Rim3dOverlayInfoConfig::updateVisCellStatsIfNeeded() } else if (eclipseView) { - size_t scalarIndex = eclipseView->cellResult()->scalarResultIndex(); - calc = new RigEclipseNativeVisibleCellsStatCalc(eclipseView->currentGridCellResults()->cellResults(), - scalarIndex, + if ( eclipseView->cellResult()->resultType() == RimDefines::FLOW_DIAGNOSTICS ) + { + RigFlowDiagResultAddress resAddr = eclipseView->cellResult()->flowDiagResAddress(); + RigFlowDiagResults* fldResults = eclipseView->cellResult()->flowDiagSolution()->flowDiagResults(); + calc = new RigFlowDiagVisibleCellsStatCalc(fldResults, + resAddr, eclipseView->currentTotalCellVisibility().p()); + + } + else + { + size_t scalarIndex = eclipseView->cellResult()->scalarResultIndex(); + calc = new RigEclipseNativeVisibleCellsStatCalc(eclipseView->currentGridCellResults()->cellResults(), + scalarIndex, + eclipseView->currentTotalCellVisibility().p()); + } } m_visibleCellStatistics = new RigStatisticsDataCache(calc.p()); diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h index 47dbd1e3fc..3852387beb 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h @@ -65,6 +65,9 @@ public: protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual caf::PdmFieldHandle* objectToggleField(); + + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + private: void updateEclipse3DInfo(RimEclipseView * reservoirView); diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 37b2250550..598b7806e8 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -66,6 +66,7 @@ ${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.cpp ${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.cpp ${CEE_CURRENT_LIST_DIR}RigResultModifierFactory.cpp ${CEE_CURRENT_LIST_DIR}RigFormationNames.cpp +${CEE_CURRENT_LIST_DIR}RigFlowDiagResultAddress.cpp ${CEE_CURRENT_LIST_DIR}RigFlowDiagResults.cpp ${CEE_CURRENT_LIST_DIR}RigFlowDiagResultFrames.cpp ${CEE_CURRENT_LIST_DIR}RigFlowDiagSolverInterface.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.cpp b/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.cpp new file mode 100644 index 0000000000..c21712362c --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.cpp @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigFlowDiagResultAddress.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigFlowDiagResultAddress::isNativeResult() const +{ + return (((variableName == RIG_FLD_TOF_RESNAME) || (variableName == RIG_FLD_CELL_FRACTION_RESNAME)) && selectedTracerNames.size() <= 1); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RigFlowDiagResultAddress::uiText() +{ + std::string uiVarname = variableName; + + std::string uitext = uiVarname; + uitext += "("; + for (const std::string& tracerName : selectedTracerNames) + { + uitext += " " + tracerName; + } + uitext += ")"; + return uitext; +} + + diff --git a/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.h b/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.h index 57cff37897..89fea6e947 100644 --- a/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.h +++ b/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.h @@ -38,8 +38,9 @@ public: selectedTracerNames.insert(tracerName); } - bool isNativeResult() const { return ( ( (variableName == RIG_FLD_TOF_RESNAME) || (variableName == RIG_FLD_CELL_FRACTION_RESNAME) ) && selectedTracerNames.size() <= 1); } + bool isNativeResult() const; + std::string uiText(); std::string variableName; std::set selectedTracerNames; diff --git a/ApplicationCode/ReservoirDataModel/RigFlowDiagResults.cpp b/ApplicationCode/ReservoirDataModel/RigFlowDiagResults.cpp index 678629b0f3..b2a1f3eeb6 100644 --- a/ApplicationCode/ReservoirDataModel/RigFlowDiagResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigFlowDiagResults.cpp @@ -201,6 +201,9 @@ std::vector* RigFlowDiagResults::calculateDerivedResult(const RigFlowDia } } + /// Test to remove all averaging + // if (injectorTOFs.size()) averageTof = (*injectorTOFs[0]); + return &averageTof; } else if (resVarAddr.variableName == RIG_FLD_CELL_FRACTION_RESNAME)
Min P10 Mean P90 Max Sum
%1 %2 %3 %4 %5 %6