From eaefaf4980e823366c124dca0ef68f1ad5acf413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 23 Nov 2017 15:11:07 +0100 Subject: [PATCH] #2119, #2072 Handle well flow condition and total flow --- .../Flow/RimWellPlotTools.cpp | 15 +- .../ProjectDataModel/Flow/RimWellPltPlot.cpp | 174 +++++++++++------- .../ProjectDataModel/Flow/RimWellPltPlot.h | 3 +- .../ProjectDataModel/RimWellLogFile.h | 17 +- 4 files changed, 127 insertions(+), 82 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp index 4b335c48cc..d6ce97cd2c 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp @@ -810,14 +810,15 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellN } // Create formatted options of all the timesteps - - std::vector allTimeSteps; - for (const std::pair>& timeStepPair : timestepsToShowWithSources) + QString dateFormatString; { - allTimeSteps.push_back(timeStepPair.first); + std::vector allTimeSteps; + for ( const std::pair>& timeStepPair : timestepsToShowWithSources ) + { + allTimeSteps.push_back(timeStepPair.first); + } + dateFormatString = RimTools::createTimeFormatStringFromDates(allTimeSteps); } - const QString dateFormatString = RimTools::createTimeFormatStringFromDates(allTimeSteps); - for (const std::pair>& timeStepPair : timestepsToShowWithSources) { @@ -836,11 +837,11 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellN } optionText += " \t[ "; - if (hasObs) optionText += "O "; if (hasRft) optionText += "R "; if (hasGrid) optionText += "G"; optionText += " ]"; + options.push_back(caf::PdmOptionItemInfo(optionText, timeStepPair.first)); } } diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp index 2d757da905..2902a69e8a 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp @@ -87,6 +87,7 @@ void caf::AppEnum< FlowPhase>::setUp() addItem(FLOW_PHASE_OIL, "PHASE_OIL", "Oil"); addItem(FLOW_PHASE_GAS, "PHASE_GAS", "Gas"); addItem(FLOW_PHASE_WATER, "PHASE_WATER", "Water"); + addItem(FLOW_PHASE_TOTAL, "PHASE_TOTAL", "Total"); } } @@ -128,11 +129,13 @@ RimWellPltPlot::RimWellPltPlot() m_selectedTimeSteps.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); m_selectedTimeSteps.uiCapability()->setAutoAddingOptionFromValue(false); - CAF_PDM_InitFieldNoDefault(&m_phaseSelectionMode, "PhaseSelectionMode", "Mode", "", "", ""); + CAF_PDM_InitField(&m_useStandardConditionCurves, "showStandardConditionCurves", true, "Standard Volume", "", "", ""); + CAF_PDM_InitField(&m_useReservoirConditionCurves, "showReservoirConditionCurves", true, "Reservoir Volume", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_phases, "Phases", "Phases", "", "", ""); m_phases.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName()); m_phases = std::vector>({ FLOW_PHASE_OIL, FLOW_PHASE_GAS, FLOW_PHASE_WATER }); + m_phases.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); this->setAsPlotMdiWindow(); m_doInitAfterLoad = false; @@ -492,13 +495,21 @@ void RimWellPltPlot::syncCurvesFromUiSelection() RimProject* proj = RiaApplication::instance()->project(); RimWellPath* wellPath = RimWellPlotTools::wellPathByWellPathNameOrSimWellName(m_wellPathName); + QString dateFormatString; + { + std::vector allTimeSteps; + for ( const RiaRftPltCurveDefinition& curveDefToAdd : curveDefs ) + { + allTimeSteps.push_back(curveDefToAdd.timeStep()); + } + dateFormatString = RimTools::createTimeFormatStringFromDates(allTimeSteps); + } + // Add curves for (const RiaRftPltCurveDefinition& curveDefToAdd : curveDefs) { - std::set selectedPhases = m_phaseSelectionMode == FLOW_TYPE_PHASE_SPLIT ? - std::set(m_phases().begin(), m_phases().end()) : - std::set({ FLOW_PHASE_TOTAL }); - + std::set selectedPhases = std::set(m_phases().begin(), m_phases().end()) ; + RifDataSourceForRftPlt sourceDef = curveDefToAdd.address(); QDateTime timeStep = curveDefToAdd.timeStep(); @@ -506,10 +517,10 @@ void RimWellPltPlot::syncCurvesFromUiSelection() QString curveName; { - curveName += sourceDef.eclCase() ? sourceDef.eclCase()->caseUserDescription() : ""; + curveName += sourceDef.eclCase() ? sourceDef.eclCase()->caseUserDescription() : ""; curveName += sourceDef.wellLogFile() ? sourceDef.wellLogFile()->name() : ""; if ( sourceDef.sourceType() == RifDataSourceForRftPlt::RFT ) curveName += ", RFT"; - curveName += ", " + timeStep.toString(); + curveName += ", " + timeStep.toString(dateFormatString); } if ( sourceDef.sourceType() == RifDataSourceForRftPlt::RFT ) @@ -523,41 +534,64 @@ void RimWellPltPlot::syncCurvesFromUiSelection() resultPointCalc.reset(new RigSimWellResultPointCalculator(m_wellPathName, dynamic_cast(sourceDef.eclCase()), timeStep)); - } if (resultPointCalc != nullptr) { if ( resultPointCalc->pipeBranchCLCoords().size() ) { - - RigAccWellFlowCalculator wfAccumulator(resultPointCalc->pipeBranchCLCoords(), - resultPointCalc->pipeBranchWellResultPoints(), - resultPointCalc->pipeBranchMeasuredDepths(), - false); // m_phaseSelectionMode() != FLOW_TYPE_PHASE_SPLIT); The total flow is reservoir conditions must be careful - - const std::vector& depthValues = wfAccumulator.pseudoLengthFromTop(0); - std::vector tracerNames = wfAccumulator.tracerNames(); - for ( const QString& tracerName: tracerNames ) + if ( selectedPhases.count(FLOW_PHASE_TOTAL) + && m_useReservoirConditionCurves() + && sourceDef.sourceType() == RifDataSourceForRftPlt::GRID ) { - auto color = tracerName == RIG_FLOW_OIL_NAME ? cvf::Color3f::DARK_GREEN : - tracerName == RIG_FLOW_GAS_NAME ? cvf::Color3f::DARK_RED : - tracerName == RIG_FLOW_WATER_NAME ? cvf::Color3f::BLUE : - cvf::Color3f::DARK_GRAY; + RigAccWellFlowCalculator wfTotalAccumulator(resultPointCalc->pipeBranchCLCoords(), + resultPointCalc->pipeBranchWellResultPoints(), + resultPointCalc->pipeBranchMeasuredDepths(), + true); - if ( tracerName == RIG_FLOW_OIL_NAME && selectedPhases.count(FLOW_PHASE_OIL) - || tracerName == RIG_FLOW_GAS_NAME && selectedPhases.count(FLOW_PHASE_GAS) - || tracerName == RIG_FLOW_WATER_NAME && selectedPhases.count(FLOW_PHASE_WATER) - || tracerName == RIG_FLOW_TOTAL_NAME && selectedPhases.count(FLOW_PHASE_TOTAL) ) + const std::vector& depthValues = wfTotalAccumulator.pseudoLengthFromTop(0); + + const std::vector accFlow = wfTotalAccumulator.accumulatedTracerFlowPrPseudoLength(RIG_FLOW_TOTAL_NAME, 0); + addStackedCurve(curveName + ", " + RIG_FLOW_TOTAL_NAME + " [R]", + depthValues, + accFlow, + plotTrack, + cvf::Color3f::DARK_GRAY, + curveGroupId, + false); + curveGroupId++; + } + + if ( m_useStandardConditionCurves() ) + { + RigAccWellFlowCalculator wfPhaseAccumulator(resultPointCalc->pipeBranchCLCoords(), + resultPointCalc->pipeBranchWellResultPoints(), + resultPointCalc->pipeBranchMeasuredDepths(), + false); + + + const std::vector& depthValues = wfPhaseAccumulator.pseudoLengthFromTop(0); + std::vector tracerNames = wfPhaseAccumulator.tracerNames(); + for ( const QString& tracerName: tracerNames ) { - const std::vector accFlow = wfAccumulator.accumulatedTracerFlowPrPseudoLength(tracerName, 0); - addStackedCurve(curveName + ", " + tracerName, - depthValues, - accFlow, - plotTrack, - color, - curveGroupId, - false); + auto color = tracerName == RIG_FLOW_OIL_NAME ? cvf::Color3f::DARK_GREEN : + tracerName == RIG_FLOW_GAS_NAME ? cvf::Color3f::DARK_RED : + tracerName == RIG_FLOW_WATER_NAME ? cvf::Color3f::BLUE : + cvf::Color3f::DARK_GRAY; + + if ( tracerName == RIG_FLOW_OIL_NAME && selectedPhases.count(FLOW_PHASE_OIL) + || tracerName == RIG_FLOW_GAS_NAME && selectedPhases.count(FLOW_PHASE_GAS) + || tracerName == RIG_FLOW_WATER_NAME && selectedPhases.count(FLOW_PHASE_WATER) ) + { + const std::vector accFlow = wfPhaseAccumulator.accumulatedTracerFlowPrPseudoLength(tracerName, 0); + addStackedCurve(curveName + ", " + tracerName + " [S]", + depthValues, + accFlow, + plotTrack, + color, + curveGroupId, + false); + } } } } @@ -565,47 +599,58 @@ void RimWellPltPlot::syncCurvesFromUiSelection() else if ( sourceDef.sourceType() == RifDataSourceForRftPlt::OBSERVED ) { RimWellLogFile* const wellLogFile = sourceDef.wellLogFile(); - if ( wellLogFile ) + if ( sourceDef.wellLogFile() && sourceDef.wellLogFile()->wellLogFileData() ) { - RigWellLogFile* wellLogFileData = wellLogFile->wellLogFileData(); + RimWellLogFile::WellFlowCondition flowCondition = sourceDef.wellLogFile()->wellFlowRateCondition(); - if ( wellLogFileData ) + if ( (m_useStandardConditionCurves() && flowCondition == RimWellLogFile::WELL_FLOW_COND_STANDARD) + || (m_useReservoirConditionCurves() && flowCondition == RimWellLogFile::WELL_FLOW_COND_RESERVOIR) ) { - std::vector channels = RimWellPlotTools::getFlowChannelsFromWellFile(wellLogFile); - - std::multiset > sortedChannels; + using ChannelValNameIdxTuple = std::tuple ; + + RigWellLogFile* wellLogFileData = sourceDef.wellLogFile()->wellLogFileData(); + + QStringList channelNames = wellLogFileData->wellLogChannelNames(); + + std::multiset< ChannelValNameIdxTuple > sortedChannels; std::vector > channelData; - channelData.resize(channels.size()); - - for (size_t chIdx = 0; chIdx < channels.size(); ++chIdx) + channelData.resize(channelNames.size()); + + for ( int chIdx = 0; chIdx < channelNames.size(); ++chIdx ) { - QString channelName = channels[chIdx]->name(); + QString channelName = channelNames[chIdx]; channelData[chIdx] = wellLogFileData->values(channelName); - if (channelData[chIdx].size()) + if ( channelData[chIdx].size() ) { - sortedChannels.insert(std::tuple(-fabs(channelData[chIdx].front()), channelName, chIdx) ); + sortedChannels.insert(ChannelValNameIdxTuple(-fabs(channelData[chIdx].front()), channelName, chIdx)); } } std::vector depthValues = wellLogFileData->depthValues(); + QString conditionName = (flowCondition == RimWellLogFile::WELL_FLOW_COND_RESERVOIR) ? " [R]" : " [S]"; - for ( const std::tuple& channelInfo: sortedChannels ) + for ( const ChannelValNameIdxTuple& channelInfo: sortedChannels ) { const auto& channelName = std::get<1>(channelInfo); - if (selectedPhases.count(RimWellPlotTools::flowPhaseFromChannelName(channelName)) > 0) + if ( selectedPhases.count(RimWellPlotTools::flowPhaseFromChannelName(channelName)) > 0 ) { - auto color = RimWellPlotTools::isOilFlowChannel(channelName) ? cvf::Color3f::DARK_GREEN : - RimWellPlotTools::isGasFlowChannel(channelName) ? cvf::Color3f::DARK_RED : + auto color = RimWellPlotTools::isOilFlowChannel(channelName) ? cvf::Color3f::DARK_GREEN : + RimWellPlotTools::isGasFlowChannel(channelName) ? cvf::Color3f::DARK_RED : RimWellPlotTools::isWaterFlowChannel(channelName) ? cvf::Color3f::BLUE : cvf::Color3f::DARK_GRAY; - addStackedCurve(curveName + ", " + channelName, - depthValues, + + addStackedCurve(curveName + ", " + channelName + conditionName, + depthValues, channelData[std::get<2>(channelInfo)], - plotTrack, + plotTrack, color, - curveGroupId, + curveGroupId, true); + + // Total flow channel will end up first, so just increment the group + // idx to make the rest of the phases group together + if ( RimWellPlotTools::isTotalFlowChannel(channelName) ) curveGroupId++; } } } @@ -797,14 +842,12 @@ QList RimWellPltPlot::calculateValueOptions(const caf::P options); } - if (fieldNeedingOptions == &m_phaseSelectionMode) - { - } - else if (fieldNeedingOptions == &m_phases) + if (fieldNeedingOptions == &m_phases) { options.push_back(caf::PdmOptionItemInfo("Oil", FLOW_PHASE_OIL)); options.push_back(caf::PdmOptionItemInfo("Gas", FLOW_PHASE_GAS)); options.push_back(caf::PdmOptionItemInfo("Water", FLOW_PHASE_WATER)); + options.push_back(caf::PdmOptionItemInfo("Total", FLOW_PHASE_TOTAL)); } return options; @@ -847,8 +890,9 @@ void RimWellPltPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c //m_wellLogPlot->setShowDescription(m_showPlotTitle); } - if (changedField == &m_phaseSelectionMode || - changedField == &m_phases) + if ( changedField == &m_useStandardConditionCurves + || changedField == &m_useReservoirConditionCurves + || changedField == &m_phases) { syncCurvesFromUiSelection(); } @@ -894,15 +938,11 @@ void RimWellPltPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& caf::PdmUiGroup* timeStepsGroup = uiOrdering.addNewGroupWithKeyword("Time Steps", "TimeSteps"); timeStepsGroup->add(&m_selectedTimeSteps); - caf::PdmUiGroup* flowGroup = uiOrdering.addNewGroupWithKeyword("Phase Selection", "PhaseSelection"); - flowGroup->add(&m_phaseSelectionMode); + caf::PdmUiGroup* flowGroup = uiOrdering.addNewGroupWithKeyword("Curve Selection", "PhaseSelection"); + flowGroup->add(&m_useStandardConditionCurves); + flowGroup->add(&m_useReservoirConditionCurves); - if (m_phaseSelectionMode == FLOW_TYPE_PHASE_SPLIT) - { - flowGroup->add(&m_phases); - } - - //uiOrdering.add(&m_showPlotTitle); + flowGroup->add(&m_phases); if (m_wellLogPlot && m_wellLogPlot->trackCount() > 0) { diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.h b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.h index dfd0c0f0c1..50a17b5c9f 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.h @@ -144,7 +144,8 @@ private: caf::PdmChildField m_wellLogPlot; - caf::PdmField> m_phaseSelectionMode; + caf::PdmField m_useStandardConditionCurves; + caf::PdmField m_useReservoirConditionCurves; caf::PdmField>> m_phases; bool m_doInitAfterLoad; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFile.h b/ApplicationCode/ProjectDataModel/RimWellLogFile.h index db47777333..160c3c6fa8 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFile.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogFile.h @@ -42,12 +42,6 @@ class RimWellLogFile : public caf::PdmObject { CAF_PDM_HEADER_INIT; - enum WellFlowCondition - { - WELL_FLOW_COND_RESERVOIR, - WELL_FLOW_COND_STANDARD - }; - const static QDateTime DEFAULT_DATE_TIME; public: @@ -70,6 +64,14 @@ public: bool hasFlowData() const; + enum WellFlowCondition + { + WELL_FLOW_COND_RESERVOIR, + WELL_FLOW_COND_STANDARD + }; + + RimWellLogFile::WellFlowCondition wellFlowRateCondition() const { return m_wellFlowCondition(); } + private: virtual void setupBeforeSave() override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; @@ -90,7 +92,8 @@ private: caf::PdmField m_name; caf::PdmField m_date; bool m_lasFileHasValidDate; - caf::PdmField> m_wellFlowCondition; + caf::PdmField> + m_wellFlowCondition; caf::PdmField m_invalidDateMessage; };