mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1118 Calculate and display flow rate
This commit is contained in:
@@ -9,6 +9,7 @@ ${CEE_CURRENT_LIST_DIR}RimFlowDiagSolution.h
|
||||
${CEE_CURRENT_LIST_DIR}RimFlowPlotCollection.h
|
||||
${CEE_CURRENT_LIST_DIR}RimWellAllocationPlot.h
|
||||
${CEE_CURRENT_LIST_DIR}RimTotalWellAllocationPlot.h
|
||||
${CEE_CURRENT_LIST_DIR}RimWellFlowRateCurve.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -16,6 +17,7 @@ ${CEE_CURRENT_LIST_DIR}RimFlowDiagSolution.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimFlowPlotCollection.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimWellAllocationPlot.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimTotalWellAllocationPlot.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimWellFlowRateCurve.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
@@ -51,3 +51,13 @@ RimFlowPlotCollection::~RimFlowPlotCollection()
|
||||
|
||||
flowPlots.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFlowPlotCollection::closeDefaultPlotWindowAndDeletePlots()
|
||||
{
|
||||
defaultPlot->removeFromMdiAreaAndDeleteViewWidget();
|
||||
|
||||
flowPlots.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ public:
|
||||
RimFlowPlotCollection();
|
||||
virtual ~RimFlowPlotCollection();
|
||||
|
||||
void closeDefaultPlotWindowAndDeletePlots();
|
||||
|
||||
caf::PdmChildField<RimWellAllocationPlot*> defaultPlot;
|
||||
caf::PdmChildArrayField<RimWellAllocationPlot*> flowPlots;
|
||||
};
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigSimulationWellCenterLineCalculator.h"
|
||||
#include "RigSimulationWellCoordsAndMD.h"
|
||||
#include "RigSingleWellResultsData.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
@@ -32,6 +33,7 @@
|
||||
#include "RimEclipseWellCollection.h"
|
||||
#include "RimFlowDiagSolution.h"
|
||||
#include "RimTotalWellAllocationPlot.h"
|
||||
#include "RimWellFlowRateCurve.h"
|
||||
#include "RimWellLogPlot.h"
|
||||
#include "RimWellLogTrack.h"
|
||||
|
||||
@@ -128,7 +130,6 @@ void RimWellAllocationPlot::updateFromWell()
|
||||
|
||||
if (!wellResults) return;
|
||||
|
||||
size_t branchCount = 0;
|
||||
|
||||
const RigWellResultFrame* wellResultFrame = nullptr;
|
||||
std::vector< std::vector <cvf::Vec3d> > pipeBranchesCLCoords;
|
||||
@@ -142,33 +143,70 @@ void RimWellAllocationPlot::updateFromWell()
|
||||
pipeBranchesCLCoords,
|
||||
pipeBranchesCellIds);
|
||||
|
||||
branchCount = pipeBranchesCLCoords.size();
|
||||
|
||||
size_t existingTrackCount = accumulatedWellFlowPlot()->trackCount();
|
||||
accumulatedWellFlowPlot()->setDescription("Accumulated Well Flow (" + m_wellName + ")");
|
||||
|
||||
size_t neededExtraTrackCount = branchCount - existingTrackCount;
|
||||
for (size_t etc = 0; etc < neededExtraTrackCount; ++etc)
|
||||
|
||||
// Delete existing tracks
|
||||
{
|
||||
RimWellLogTrack* plotTrack = new RimWellLogTrack();
|
||||
accumulatedWellFlowPlot()->addTrack(plotTrack);
|
||||
}
|
||||
|
||||
for (size_t etc = branchCount; etc < existingTrackCount; ++etc)
|
||||
{
|
||||
accumulatedWellFlowPlot()->removeTrackByIndex(accumulatedWellFlowPlot()->trackCount()- 1);
|
||||
std::vector<RimWellLogTrack*> tracks;
|
||||
accumulatedWellFlowPlot()->descendantsIncludingThisOfType(tracks);
|
||||
|
||||
for (RimWellLogTrack* t : tracks)
|
||||
{
|
||||
accumulatedWellFlowPlot()->removeTrack(t);
|
||||
delete t;
|
||||
}
|
||||
}
|
||||
|
||||
CVF_ASSERT(accumulatedWellFlowPlot()->trackCount() == 0);
|
||||
|
||||
size_t branchCount = pipeBranchesCLCoords.size();
|
||||
for (size_t brIdx = 0; brIdx < branchCount; ++brIdx)
|
||||
{
|
||||
RimWellLogTrack* plotTrack = accumulatedWellFlowPlot()->trackByIndex(brIdx);
|
||||
RimWellLogTrack* plotTrack = new RimWellLogTrack();
|
||||
|
||||
plotTrack->setDescription(QString("Branch %1").arg(brIdx+1));
|
||||
// TODO: Description is overwritten by RimWellLogPlot::updateTrackNames()
|
||||
// Add flag to control if this behavior
|
||||
plotTrack->setDescription(QString("Branch %1").arg(brIdx + 1));
|
||||
|
||||
accumulatedWellFlowPlot()->addTrack(plotTrack);
|
||||
|
||||
std::vector<cvf::Vec3d> curveCoords;
|
||||
std::vector<double> flowRate;
|
||||
|
||||
{
|
||||
std::vector<cvf::Vec3d> branchCoords = pipeBranchesCLCoords[brIdx];
|
||||
std::vector<RigWellResultPoint> branchResultPoints = pipeBranchesCellIds[brIdx];
|
||||
|
||||
RigWellResultPoint prevResultPoint;
|
||||
|
||||
for (size_t i = 0; i < branchResultPoints.size(); i++)
|
||||
{
|
||||
const RigWellResultPoint& resultPoint = branchResultPoints[i];
|
||||
|
||||
if (i > 0 && prevResultPoint.m_gridCellIndex != resultPoint.m_gridCellIndex)
|
||||
{
|
||||
// Add an extra curve point when a cell transition is detected
|
||||
curveCoords.push_back(branchCoords[i]);
|
||||
flowRate.push_back(prevResultPoint.m_flowRate);
|
||||
}
|
||||
|
||||
// Todo: Calculate curve data
|
||||
curveCoords.push_back(branchCoords[i]);
|
||||
flowRate.push_back(branchResultPoints[i].m_flowRate);
|
||||
|
||||
prevResultPoint = resultPoint;
|
||||
}
|
||||
}
|
||||
|
||||
RigSimulationWellCoordsAndMD helper(curveCoords);
|
||||
|
||||
RimWellFlowRateCurve* curve = new RimWellFlowRateCurve;
|
||||
curve->setFlowValues(helper.measuredDepths(), flowRate);
|
||||
|
||||
plotTrack->addCurve(curve);
|
||||
|
||||
curve->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
setDescription("Well Allocation (" + m_wellName + ")");
|
||||
accumulatedWellFlowPlot()->updateConnectedEditors();
|
||||
@@ -215,7 +253,7 @@ QList<caf::PdmOptionItemInfo> RimWellAllocationPlot::calculateValueOptions(const
|
||||
if (fieldNeedingOptions == &m_wellName)
|
||||
{
|
||||
std::set<QString> sortedWellNames;
|
||||
if ( m_case )
|
||||
if ( m_case && m_case->reservoirData() )
|
||||
{
|
||||
const cvf::Collection<RigSingleWellResultsData>& wellRes = m_case->reservoirData()->wellResults();
|
||||
|
||||
@@ -240,7 +278,7 @@ QList<caf::PdmOptionItemInfo> RimWellAllocationPlot::calculateValueOptions(const
|
||||
{
|
||||
QStringList timeStepNames;
|
||||
|
||||
if (m_case)
|
||||
if (m_case && m_case->reservoirData())
|
||||
{
|
||||
timeStepNames = m_case->timeStepStrings();
|
||||
}
|
||||
@@ -254,6 +292,23 @@ QList<caf::PdmOptionItemInfo> RimWellAllocationPlot::calculateValueOptions(const
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellAllocationPlot::wellName() const
|
||||
{
|
||||
return m_wellName();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellAllocationPlot::removeFromMdiAreaAndDeleteViewWidget()
|
||||
{
|
||||
removeMdiWindowFromMdiArea();
|
||||
deleteViewWidget();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -272,7 +327,6 @@ void RimWellAllocationPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedF
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -66,6 +66,10 @@ public:
|
||||
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
||||
|
||||
QString wellName() const;
|
||||
|
||||
void removeFromMdiAreaAndDeleteViewWidget();
|
||||
|
||||
protected:
|
||||
// Overridden PDM methods
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
|
||||
|
||||
135
ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp
Normal file
135
ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp
Normal file
@@ -0,0 +1,135 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimWellFlowRateCurve.h"
|
||||
|
||||
#include "RimWellAllocationPlot.h"
|
||||
|
||||
#include "RiuLineSegmentQwtPlotCurve.h"
|
||||
|
||||
#include "qwt_plot.h"
|
||||
#include "RimWellLogPlot.h"
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimWellFlowRateCurve, "RimWellFlowRateCurve");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellFlowRateCurve::RimWellFlowRateCurve()
|
||||
{
|
||||
CAF_PDM_InitObject("Flow Rate Curve", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellFlowRateCurve::~RimWellFlowRateCurve()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellFlowRateCurve::wellName() const
|
||||
{
|
||||
QString name;
|
||||
|
||||
RimWellAllocationPlot* wap = wellAllocationPlot();
|
||||
|
||||
if (wap)
|
||||
{
|
||||
name = wap->wellName();
|
||||
}
|
||||
else
|
||||
{
|
||||
name = "Undefined";
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellFlowRateCurve::wellLogChannelName() const
|
||||
{
|
||||
return "Flow Rate";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellFlowRateCurve::createCurveAutoName()
|
||||
{
|
||||
return QString("%1 (%2)").arg(wellLogChannelName()).arg(wellName());
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellFlowRateCurve::onLoadDataAndUpdate()
|
||||
{
|
||||
RimWellLogCurve::updateCurvePresentation();
|
||||
|
||||
if (isCurveVisible())
|
||||
{
|
||||
RimWellLogPlot* wellLogPlot;
|
||||
firstAncestorOrThisOfType(wellLogPlot);
|
||||
CVF_ASSERT(wellLogPlot);
|
||||
|
||||
m_qwtPlotCurve->setTitle(createCurveAutoName());
|
||||
|
||||
RimDefines::DepthUnitType displayUnit = RimDefines::UNIT_METER;
|
||||
m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(), m_curveData->measuredDepthPlotValues(displayUnit).data(), static_cast<int>(m_curveData->xPlotValues().size()));
|
||||
m_qwtPlotCurve->setLineSegmentStartStopIndices(m_curveData->polylineStartStopIndices());
|
||||
|
||||
updateZoomInParentPlot();
|
||||
|
||||
if (m_parentQwtPlot) m_parentQwtPlot->replot();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellAllocationPlot* RimWellFlowRateCurve::wellAllocationPlot() const
|
||||
{
|
||||
RimWellAllocationPlot* wap = nullptr;
|
||||
this->firstAncestorOrThisOfType(wap);
|
||||
|
||||
return wap;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellFlowRateCurve::setFlowValues(const std::vector<double>& measuredDepths, const std::vector<double>& flowRates)
|
||||
{
|
||||
m_curveData = new RigWellLogCurveData;
|
||||
m_curveData->setValuesAndMD(flowRates, measuredDepths, RimDefines::UNIT_METER, false);
|
||||
}
|
||||
|
||||
53
ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h
Normal file
53
ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RimWellLogCurve.h"
|
||||
|
||||
#include "cafPdmPtrField.h"
|
||||
#include "cafPdmChildField.h"
|
||||
|
||||
class RimEclipseResultCase;
|
||||
class RimWellAllocationPlot;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimWellFlowRateCurve : public RimWellLogCurve
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
RimWellFlowRateCurve();
|
||||
virtual ~RimWellFlowRateCurve();
|
||||
|
||||
void setFlowValues(const std::vector<double>& measuredDepths, const std::vector<double>& flowRates);
|
||||
|
||||
virtual QString wellName() const override;
|
||||
virtual QString wellLogChannelName() const override;
|
||||
|
||||
protected:
|
||||
virtual QString createCurveAutoName() override;
|
||||
virtual void onLoadDataAndUpdate() override;
|
||||
|
||||
private:
|
||||
RimWellAllocationPlot* wellAllocationPlot() const;
|
||||
};
|
||||
|
||||
@@ -169,7 +169,8 @@ void RimMainPlotCollection::deleteAllContainedObjects()
|
||||
{
|
||||
m_wellLogPlotCollection()->wellLogPlots.deleteAllChildObjects();
|
||||
m_summaryPlotCollection()->summaryPlots.deleteAllChildObjects();
|
||||
m_flowPlotCollection()->flowPlots.deleteAllChildObjects();
|
||||
|
||||
m_flowPlotCollection()->closeDefaultPlotWindowAndDeletePlots();
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
Reference in New Issue
Block a user