From 8f65bd3fee0b2f11c126f69363142e9d62c7aa42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 14 Dec 2016 09:50:30 +0100 Subject: [PATCH] #1028 Flow Diag Solution object. #1029 Flow Diag Result type in Result Definition along with some refactoring. --- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../ProjectDataModel/RimDefines.cpp | 1 + ApplicationCode/ProjectDataModel/RimDefines.h | 1 + .../ProjectDataModel/RimEclipseResultCase.cpp | 21 ++ .../ProjectDataModel/RimEclipseResultCase.h | 4 + .../RimEclipseResultDefinition.cpp | 336 +++++++++++++----- .../RimEclipseResultDefinition.h | 28 +- .../ProjectDataModel/RimFlowDiagSolution.cpp | 117 ++++++ .../ProjectDataModel/RimFlowDiagSolution.h | 61 ++++ 9 files changed, 472 insertions(+), 99 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimFlowDiagSolution.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimFlowDiagSolution.h diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index dbe7ba7e24..244985ff7b 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -47,6 +47,7 @@ ${CEE_CURRENT_LIST_DIR}RimFault.h ${CEE_CURRENT_LIST_DIR}RimFaultCollection.h ${CEE_CURRENT_LIST_DIR}RimFormationNames.h ${CEE_CURRENT_LIST_DIR}RimFormationNamesCollection.h +${CEE_CURRENT_LIST_DIR}RimFlowDiagSolution.h ${CEE_CURRENT_LIST_DIR}RimMockModelSettings.h ${CEE_CURRENT_LIST_DIR}RimTernaryLegendConfig.h ${CEE_CURRENT_LIST_DIR}RimEclipseFaultColors.h @@ -128,6 +129,7 @@ ${CEE_CURRENT_LIST_DIR}RimFault.cpp ${CEE_CURRENT_LIST_DIR}RimFaultCollection.cpp ${CEE_CURRENT_LIST_DIR}RimFormationNames.cpp ${CEE_CURRENT_LIST_DIR}RimFormationNamesCollection.cpp +${CEE_CURRENT_LIST_DIR}RimFlowDiagSolution.cpp ${CEE_CURRENT_LIST_DIR}RimMockModelSettings.cpp ${CEE_CURRENT_LIST_DIR}RimTernaryLegendConfig.cpp ${CEE_CURRENT_LIST_DIR}RimEclipseFaultColors.cpp diff --git a/ApplicationCode/ProjectDataModel/RimDefines.cpp b/ApplicationCode/ProjectDataModel/RimDefines.cpp index c590e393f1..a4795ac89d 100644 --- a/ApplicationCode/ProjectDataModel/RimDefines.cpp +++ b/ApplicationCode/ProjectDataModel/RimDefines.cpp @@ -32,6 +32,7 @@ namespace caf addItem(RimDefines::GENERATED, "GENERATED", "Generated"); addItem(RimDefines::INPUT_PROPERTY, "INPUT_PROPERTY", "Input Property"); addItem(RimDefines::FORMATION_NAMES, "FORMATION_NAMES", "Formation Names"); + addItem(RimDefines::FLOW_DIAGNOSTICS, "FLOW_DIAGNOSTICS", "Flow Diagnostics"); setDefault(RimDefines::DYNAMIC_NATIVE); } diff --git a/ApplicationCode/ProjectDataModel/RimDefines.h b/ApplicationCode/ProjectDataModel/RimDefines.h index 06a35b1d1a..4fb5a5b4a9 100644 --- a/ApplicationCode/ProjectDataModel/RimDefines.h +++ b/ApplicationCode/ProjectDataModel/RimDefines.h @@ -33,6 +33,7 @@ public: GENERATED, INPUT_PROPERTY, FORMATION_NAMES, + FLOW_DIAGNOSTICS, REMOVED }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp index 2210ec9bb7..2ab655b4ec 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -34,6 +34,7 @@ #include "RimProject.h" #include "RimReservoirCellResultsStorage.h" #include "RimTools.h" +#include "RimFlowDiagSolution.h" #include "cafPdmSettings.h" #include "cafPdmUiPropertyViewDialog.h" @@ -55,6 +56,11 @@ RimEclipseResultCase::RimEclipseResultCase() CAF_PDM_InitField(&caseFileName, "CaseFileName", QString(), "Case file name", "", "" ,""); caseFileName.uiCapability()->setUiReadOnly(true); + CAF_PDM_InitFieldNoDefault (&m_flowDiagSolutions, "FlowDiagSolutions", "Flow Diagnostics Solutions", "", "", ""); + + // TODO: Create a solution by default only when flux data is available + m_flowDiagSolutions.push_back( new RimFlowDiagSolution()); + // Obsolete, unused field CAF_PDM_InitField(&caseDirectory, "CaseFolder", QString(), "Directory", "", "" ,""); caseDirectory.xmlCapability()->setIOWritable(false); @@ -298,6 +304,7 @@ cvf::ref RimEclipseResultCase::createMockModel(QString model RimEclipseResultCase::~RimEclipseResultCase() { reservoirViews.deleteAllChildObjects(); + m_flowDiagSolutions.deleteAllChildObjects(); } //-------------------------------------------------------------------------------------------------- @@ -336,6 +343,20 @@ void RimEclipseResultCase::updateFilePathsFromProjectPath(const QString& newProj } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEclipseResultCase::flowDiagSolutions() +{ + std::vector flowSols; + for ( const caf::PdmPointer& fsol: m_flowDiagSolutions ) + { + flowSols.push_back(fsol.p()); + } + + return flowSols; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.h b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.h index f0f17ccebf..bb67fa856a 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.h @@ -24,6 +24,7 @@ class RifReaderInterface; class RigMainGrid; +class RimFlowDiagSolution; //================================================================================================== // @@ -50,6 +51,7 @@ public: virtual QString gridFileName() const { return caseFileName();} virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); + std::vector flowDiagSolutions(); private: cvf::ref createMockModel(QString modelName); @@ -59,6 +61,8 @@ private: // Fields: caf::PdmField caseFileName; + caf::PdmChildArrayField m_flowDiagSolutions; + // Obsolete field caf::PdmField caseDirectory; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 91082aa2f4..f07b95589a 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -33,8 +33,10 @@ #include "RimView.h" #include "RimViewLinker.h" #include "RimWellLogCurve.h" +#include "RimFlowDiagSolution.h" #include "cafPdmUiListEditor.h" +#include "RimEclipseResultCase.h" CAF_PDM_SOURCE_INIT(RimEclipseResultDefinition, "ResultDefinition"); @@ -47,23 +49,43 @@ RimEclipseResultDefinition::RimEclipseResultDefinition() CAF_PDM_InitFieldNoDefault(&m_resultType, "ResultType", "Type", "", "", ""); m_resultType.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_porosityModel, "PorosityModelType", "Porosity", "", "", ""); m_porosityModel.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_resultVariable, "ResultVariable", RimDefines::undefinedResultName(), "Variable", "", "", "" ); m_resultVariable.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_flowSolution, "FlowDiagSolution", "Solution", "", "", ""); + m_flowSolution.uiCapability()->setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_selectedTracers, "SelectedTracers", "Tracers", "", "", ""); + m_selectedTracers.uiCapability()->setUiHidden(true); + + // Ui only fields + CAF_PDM_InitFieldNoDefault(&m_resultTypeUiField, "MResultType", "Type", "", "", ""); m_resultTypeUiField.xmlCapability()->setIOReadable(false); m_resultTypeUiField.xmlCapability()->setIOWritable(false); + CAF_PDM_InitFieldNoDefault(&m_porosityModelUiField, "MPorosityModelType", "Porosity", "", "", ""); m_porosityModelUiField.xmlCapability()->setIOReadable(false); m_porosityModelUiField.xmlCapability()->setIOWritable(false); + CAF_PDM_InitField(&m_resultVariableUiField, "MResultVariable", RimDefines::undefinedResultName(), "Result property", "", "", "" ); m_resultVariableUiField.xmlCapability()->setIOReadable(false); m_resultVariableUiField.xmlCapability()->setIOWritable(false); - - m_resultVariableUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); + + CAF_PDM_InitFieldNoDefault(&m_flowSolutionUiField, "MFlowDiagSolution", "Solution", "", "", ""); + m_flowSolutionUiField.xmlCapability()->setIOReadable(false); + m_flowSolutionUiField.xmlCapability()->setIOWritable(false); + + CAF_PDM_InitFieldNoDefault(&m_selectedTracersUiField, "MSelectedTracers", "Tracers", "", "", ""); + m_selectedTracersUiField.xmlCapability()->setIOReadable(false); + m_selectedTracersUiField.xmlCapability()->setIOWritable(false); + m_selectedTracersUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); + } //-------------------------------------------------------------------------------------------------- @@ -80,22 +102,10 @@ RimEclipseResultDefinition::~RimEclipseResultDefinition() void RimEclipseResultDefinition::setEclipseCase(RimEclipseCase* eclipseCase) { m_eclipseCase = eclipseCase; + updateFieldVisibility(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QStringList RimEclipseResultDefinition::getResultVariableListForCurrentUIFieldSettings() -{ - RimReservoirCellResultsStorage* cellResultsStorage = currentGridCellResults(); - - if (!cellResultsStorage) return QStringList(); - - if (!cellResultsStorage->cellResults()) return QStringList(); - - return cellResultsStorage->cellResults()->resultNames(m_resultTypeUiField()); -} //-------------------------------------------------------------------------------------------------- /// @@ -117,7 +127,7 @@ void RimEclipseResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha if ( &m_resultTypeUiField == changedField || &m_porosityModelUiField == changedField ) { - QStringList varList = getResultVariableListForCurrentUIFieldSettings(); + QStringList varList = getResultNamesForCurrentUiResultType(); // If the user are seeing the list with the actually selected result, select that result in the list. Otherwise select nothing. if ( m_resultTypeUiField() == m_resultType() @@ -139,6 +149,18 @@ void RimEclipseResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha m_resultType = m_resultTypeUiField; m_resultVariable = m_resultVariableUiField; + if (m_resultTypeUiField() == RimDefines::FLOW_DIAGNOSTICS) + { + m_flowSolution = m_flowSolutionUiField(); + m_selectedTracers = m_selectedTracersUiField(); + } + updateResultNameHasChanged(); + } + + if ( &m_selectedTracersUiField == changedField ) + { + m_flowSolution = m_flowSolutionUiField(); + m_selectedTracers = m_selectedTracersUiField(); updateResultNameHasChanged(); } @@ -252,99 +274,189 @@ void RimEclipseResultDefinition::updateResultNameHasChanged() //-------------------------------------------------------------------------------------------------- QList RimEclipseResultDefinition::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) { - bool showPerFaceResultsFirst = false; + QList optionItems; - RimEclipseFaultColors* rimEclipseFaultColors = nullptr; - this->firstAncestorOrThisOfType(rimEclipseFaultColors); - if (rimEclipseFaultColors) showPerFaceResultsFirst = true; - - QList optionItems = calculateValueOptionsForSpecifiedDerivedListPosition(showPerFaceResultsFirst, fieldNeedingOptions, useOptionsOnly); - - RimWellLogCurve* curve = nullptr; - this->firstAncestorOrThisOfType(curve); - - RimEclipsePropertyFilter* propFilter = nullptr; - this->firstAncestorOrThisOfType(propFilter); - - RimCellEdgeColors* cellEdge = nullptr; - this->firstAncestorOrThisOfType(cellEdge); - - if (propFilter || curve || cellEdge) + if ( m_resultTypeUiField() != RimDefines::FLOW_DIAGNOSTICS ) { - removePerCellFaceOptionItems(optionItems); + if ( fieldNeedingOptions == &m_resultVariableUiField ) + { + optionItems = calcOptionsForVariableUiFieldStandard(); + } + } + else + { + if ( fieldNeedingOptions == &m_resultVariableUiField ) + { + optionItems.push_back(caf::PdmOptionItemInfo("Time Of Flight (Weighted Sum)", "TOF")); + optionItems.push_back(caf::PdmOptionItemInfo("Tracer Concentration (Sum)", "Concentrations")); + optionItems.push_back(caf::PdmOptionItemInfo("Tracer with Max Concentration", "MaxTracer")); + optionItems.push_back(caf::PdmOptionItemInfo("Injector Producer Communication", "Communication")); + } + else if (fieldNeedingOptions == &m_flowSolutionUiField) + { + RimEclipseResultCase* eclCase; + this->firstAncestorOrThisOfType(eclCase); + if (eclCase) + { + std::vector flowSols = eclCase->flowDiagSolutions(); + for (RimFlowDiagSolution* flowSol : flowSols) + { + optionItems.push_back(caf::PdmOptionItemInfo(flowSol->userDescription(), flowSol)); + } + } + } + else if (fieldNeedingOptions == &m_selectedTracersUiField) + { + RimFlowDiagSolution* flowSol = m_flowSolutionUiField(); + if (flowSol) + { + std::set tracerNames = flowSol->tracerNames(); + std::map prefixedTracerNamesMap; + for ( const QString& tracerName : tracerNames ) + { + RimFlowDiagSolution::TracerStatusType status = flowSol->tracerStatus(tracerName); + QString prefix; + switch (status) + { + case RimFlowDiagSolution::INJECTOR: prefix = "I : "; break; + case RimFlowDiagSolution::PRODUCER: prefix = "P : "; break; + case RimFlowDiagSolution::VARYING: prefix = "I/P: "; break; + } + prefixedTracerNamesMap[prefix + tracerName] = tracerName; + } + + for (auto nameIt: prefixedTracerNamesMap) + { + optionItems.push_back(caf::PdmOptionItemInfo(nameIt.first, QVariant(nameIt.second))); + } + } + } } + (*useOptionsOnly) = true; + return optionItems; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimEclipseResultDefinition::calcOptionsForVariableUiFieldStandard() +{ + CVF_ASSERT(m_resultTypeUiField() != RimDefines::FLOW_DIAGNOSTICS); + + if (this->currentGridCellResults()) + { + QList optionList; + + QStringList cellCenterResultNames; + QStringList cellFaceResultNames; + + foreach(QString s, getResultNamesForCurrentUiResultType()) + { + if (RimDefines::isPerCellFaceResult(s)) + { + cellFaceResultNames.push_back(s); + } + else + { + cellCenterResultNames.push_back(s); + } + } + + cellCenterResultNames.sort(); + cellFaceResultNames.sort(); + + // Cell Center result names + foreach(QString s, cellCenterResultNames) + { + optionList.push_back(caf::PdmOptionItemInfo(s, s)); + } + + // Ternary Result + bool hasAtLeastOneTernaryComponent = false; + if (cellCenterResultNames.contains("SOIL")) hasAtLeastOneTernaryComponent = true; + else if (cellCenterResultNames.contains("SGAS")) hasAtLeastOneTernaryComponent = true; + else if (cellCenterResultNames.contains("SWAT")) hasAtLeastOneTernaryComponent = true; + + if (m_resultTypeUiField == RimDefines::DYNAMIC_NATIVE && hasAtLeastOneTernaryComponent) + { + optionList.push_front(caf::PdmOptionItemInfo(RimDefines::ternarySaturationResultName(), RimDefines::ternarySaturationResultName())); + } + + // Cell Face result names + bool showDerivedResultsFirstInList = false; + { + RimEclipseFaultColors* rimEclipseFaultColors = nullptr; + this->firstAncestorOrThisOfType(rimEclipseFaultColors); + + if ( rimEclipseFaultColors ) showDerivedResultsFirstInList = true; + } + + foreach(QString s, cellFaceResultNames) + { + if (showDerivedResultsFirstInList) + { + optionList.push_front(caf::PdmOptionItemInfo(s, s)); + } + else + { + optionList.push_back(caf::PdmOptionItemInfo(s, s)); + } + } + + optionList.push_front(caf::PdmOptionItemInfo(RimDefines::undefinedResultName(), RimDefines::undefinedResultName())); + + // Remove Per Cell Face options + { + RimWellLogCurve* curve = nullptr; + this->firstAncestorOrThisOfType(curve); + + RimEclipsePropertyFilter* propFilter = nullptr; + this->firstAncestorOrThisOfType(propFilter); + + RimCellEdgeColors* cellEdge = nullptr; + this->firstAncestorOrThisOfType(cellEdge); + + if ( propFilter || curve || cellEdge ) + { + removePerCellFaceOptionItems(optionList); + } + } + + return optionList; + } + + return QList(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimEclipseResultDefinition::calculateValueOptionsForSpecifiedDerivedListPosition(bool showDerivedResultsFirstInList, const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +QStringList RimEclipseResultDefinition::getResultNamesForCurrentUiResultType() { - if (fieldNeedingOptions == &m_resultVariableUiField) + if ( m_resultTypeUiField() != RimDefines::FLOW_DIAGNOSTICS ) { - if (this->currentGridCellResults()) - { - QList optionList; - - QStringList cellCenterResultNames; - QStringList cellFaceResultNames; - - foreach(QString s, getResultVariableListForCurrentUIFieldSettings()) - { - if (RimDefines::isPerCellFaceResult(s)) - { - cellFaceResultNames.push_back(s); - } - else - { - cellCenterResultNames.push_back(s); - } - } + RimReservoirCellResultsStorage* cellResultsStorage = currentGridCellResults(); - cellCenterResultNames.sort(); - cellFaceResultNames.sort(); + if ( !cellResultsStorage ) return QStringList(); - // Cell Center result names - foreach(QString s, cellCenterResultNames) - { - optionList.push_back(caf::PdmOptionItemInfo(s, s)); - } + if ( !cellResultsStorage->cellResults() ) return QStringList(); - // Ternary Result - bool hasAtLeastOneTernaryComponent = false; - if (cellCenterResultNames.contains("SOIL")) hasAtLeastOneTernaryComponent = true; - else if (cellCenterResultNames.contains("SGAS")) hasAtLeastOneTernaryComponent = true; - else if (cellCenterResultNames.contains("SWAT")) hasAtLeastOneTernaryComponent = true; - - if (m_resultTypeUiField == RimDefines::DYNAMIC_NATIVE && hasAtLeastOneTernaryComponent) - { - optionList.push_front(caf::PdmOptionItemInfo(RimDefines::ternarySaturationResultName(), RimDefines::ternarySaturationResultName())); - } - - // Cell Face result names - foreach(QString s, cellFaceResultNames) - { - if (showDerivedResultsFirstInList) - { - optionList.push_front(caf::PdmOptionItemInfo(s, s)); - } - else - { - optionList.push_back(caf::PdmOptionItemInfo(s, s)); - } - } - - optionList.push_front(caf::PdmOptionItemInfo(RimDefines::undefinedResultName(), RimDefines::undefinedResultName())); - - if (useOptionsOnly) *useOptionsOnly = true; - - return optionList; - } + return cellResultsStorage->cellResults()->resultNames(m_resultTypeUiField()); } + else + { + // TODO: Get this form some sensible place - return QList(); + QStringList flowVars; + flowVars.push_back("TOF"); + flowVars.push_back("Concentrations"); + flowVars.push_back("MaxTracer"); + flowVars.push_back("Communication"); + return flowVars; + } } //-------------------------------------------------------------------------------------------------- @@ -448,6 +560,9 @@ void RimEclipseResultDefinition::initAfterRead() m_resultTypeUiField = m_resultType; m_resultVariableUiField = m_resultVariable; + m_flowSolutionUiField = m_flowSolution(); + m_selectedTracersUiField = m_selectedTracers; + this->updateUiIconFromToggleField(); } @@ -522,6 +637,43 @@ void RimEclipseResultDefinition::updateFieldVisibility() m_porosityModelUiField.uiCapability()->setUiHidden(false); } } + +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseResultDefinition::hasDualPorFractureResult() +{ + if ( m_eclipseCase + && m_eclipseCase->reservoirData() + && m_eclipseCase->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS) + && m_eclipseCase->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->reservoirActiveCellCount() > 0 ) + { + return true; + } + + return false; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseResultDefinition::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + uiOrdering.add(&m_resultTypeUiField); + if (hasDualPorFractureResult()) + { + uiOrdering.add(&m_porosityModelUiField); + } + if ( m_resultTypeUiField() == RimDefines::FLOW_DIAGNOSTICS ) + { + uiOrdering.add(&m_flowSolutionUiField); + uiOrdering.add(&m_selectedTracersUiField); + } + uiOrdering.add(&m_resultVariableUiField); + + uiOrdering.setForgetRemainingFields(true); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h index 410766cf9a..88f54b1b5d 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h @@ -26,11 +26,13 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmPointer.h" +#include "cafPdmPtrField.h" class RigCaseCellResultsData; class RimEclipseCase; class RimEclipseView; class RimReservoirCellResultsStorage; +class RimFlowDiagSolution; //================================================================================================== /// @@ -62,38 +64,50 @@ public: RimReservoirCellResultsStorage* currentGridCellResults() const; - virtual void initAfterRead(); - - virtual void updateLegendCategorySettings() {}; - void updateResultNameHasChanged(); void updateAnyFieldHasChanged(); +protected: + virtual void updateLegendCategorySettings() {}; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + virtual void initAfterRead(); + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; -protected: void updateFieldVisibility(); + + protected: caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > m_resultType; caf::PdmField< caf::AppEnum< RimDefines::PorosityModelType > > m_porosityModel; caf::PdmField m_resultVariable; + caf::PdmPtrField m_flowSolution; + caf::PdmField > m_selectedTracers; + friend class RimEclipsePropertyFilter; friend class RimEclipseFaultColors; friend class RimWellLogExtractionCurve; // User interface only fields, to support "filtering"-like behaviour etc. + caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > m_resultTypeUiField; caf::PdmField< caf::AppEnum< RimDefines::PorosityModelType > > m_porosityModelUiField; caf::PdmField m_resultVariableUiField; + caf::PdmPtrField m_flowSolutionUiField; + caf::PdmField > m_selectedTracersUiField; + + caf::PdmPointer m_eclipseCase; private: - QList calculateValueOptionsForSpecifiedDerivedListPosition(bool showDerivedResultsFirstInList, const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly); - QStringList getResultVariableListForCurrentUIFieldSettings(); + bool hasDualPorFractureResult(); + + QList calcOptionsForVariableUiFieldStandard(); + QStringList getResultNamesForCurrentUiResultType(); static void removePerCellFaceOptionItems(QList& optionItems); }; diff --git a/ApplicationCode/ProjectDataModel/RimFlowDiagSolution.cpp b/ApplicationCode/ProjectDataModel/RimFlowDiagSolution.cpp new file mode 100644 index 0000000000..b69975630e --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimFlowDiagSolution.cpp @@ -0,0 +1,117 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- 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 "RimFlowDiagSolution.h" +#include "RimEclipseResultCase.h" +#include "RigCaseData.h" + +CAF_PDM_SOURCE_INIT(RimFlowDiagSolution, "FlowDiagSolution"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFlowDiagSolution::RimFlowDiagSolution(void) +{ + CAF_PDM_InitObject("Flow Diagnostics Solution", "", "", ""); + + //CAF_PDM_InitFieldNoDefault(&m_selectedWells, "SelectedWells", "Selected Wells","",""); + + CAF_PDM_InitField(&m_userDescription, "UserDescription", QString("All Wells") ,"Description", "", "",""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFlowDiagSolution::~RimFlowDiagSolution(void) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RimFlowDiagSolution::tracerNames() +{ + RimEclipseResultCase* eclCase; + this->firstAncestorOrThisOfType(eclCase); + + std::set tracerNameSet; + + if (eclCase) + { + const cvf::Collection& wellResults = eclCase->reservoirData()->wellResults(); + + for (size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx) + { + tracerNameSet.insert(wellResults[wIdx]->m_wellName); + } + } + + return tracerNameSet; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatus(QString tracerName) +{ + RimEclipseResultCase* eclCase; + this->firstAncestorOrThisOfType(eclCase); + TracerStatusType tracerStatus = UNDEFINED; + if ( eclCase ) + { + const cvf::Collection& wellResults = eclCase->reservoirData()->wellResults(); + + for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx ) + { + if(wellResults[wIdx]->m_wellName == tracerName) + { + for (const RigWellResultFrame& wellResFrame : wellResults[wIdx]->m_wellCellsTimeSteps) + { + if (wellResFrame.m_productionType == RigWellResultFrame::GAS_INJECTOR + || wellResFrame.m_productionType == RigWellResultFrame::OIL_INJECTOR + || wellResFrame.m_productionType == RigWellResultFrame::WATER_INJECTOR) + { + if (tracerStatus == PRODUCER) tracerStatus = VARYING; + else tracerStatus = INJECTOR; + } + else if (wellResFrame.m_productionType == RigWellResultFrame::PRODUCER) + { + if ( tracerStatus == INJECTOR ) tracerStatus = VARYING; + else tracerStatus = PRODUCER; + } + + if (tracerStatus == VARYING) break; + } + + break; + } + } + } + + return tracerStatus; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimFlowDiagSolution::userDescriptionField() +{ + return &m_userDescription; +} + diff --git a/ApplicationCode/ProjectDataModel/RimFlowDiagSolution.h b/ApplicationCode/ProjectDataModel/RimFlowDiagSolution.h new file mode 100644 index 0000000000..3bf940e184 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimFlowDiagSolution.h @@ -0,0 +1,61 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- 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. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPointer.h" +#include "cafAppEnum.h" + +class RimEclipseWell; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimFlowDiagSolution : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimFlowDiagSolution(void); + virtual ~RimFlowDiagSolution(void); + + QString userDescription() { return m_userDescription();} + + std::set tracerNames(); + + enum TracerStatusType + { + PRODUCER, + INJECTOR, + VARYING, + UNDEFINED + }; + + TracerStatusType tracerStatus(QString tracerName); + +protected: + //virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; + +private: + virtual caf::PdmFieldHandle* userDescriptionField() override; + caf::PdmField m_userDescription; + + //caf::PdmPtrArrayField m_selectedWells; +};