2017-10-23 06:57:01 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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 "RimWellPltPlot.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "RiaColorTables.h"
|
|
|
|
#include "RiaDateStringParser.h"
|
|
|
|
#include "RifReaderEclipseRft.h"
|
|
|
|
#include "RigCaseCellResultsData.h"
|
|
|
|
#include "RigEclipseCaseData.h"
|
|
|
|
#include "RigSimWellData.h"
|
|
|
|
#include "RigWellPath.h"
|
|
|
|
#include "RimEclipseCase.h"
|
|
|
|
#include "RimEclipseCaseCollection.h"
|
|
|
|
#include "RimEclipseResultCase.h"
|
|
|
|
#include "RimEclipseResultDefinition.h"
|
|
|
|
#include "RimOilField.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimTools.h"
|
|
|
|
#include "RimWellLogExtractionCurve.h"
|
|
|
|
#include "RimWellLogFile.h"
|
|
|
|
#include "RimWellLogFileChannel.h"
|
|
|
|
#include "RimWellLogFileCurve.h"
|
|
|
|
#include "RimWellLogPlot.h"
|
|
|
|
#include "RimWellLogRftCurve.h"
|
|
|
|
#include "RimWellLogTrack.h"
|
|
|
|
#include "RimWellPath.h"
|
|
|
|
#include "RimWellPathCollection.h"
|
2017-10-25 07:43:17 -05:00
|
|
|
#include "RimWellFlowRateCurve.h"
|
2017-10-23 06:57:01 -05:00
|
|
|
#include "RiuWellPltPlot.h"
|
|
|
|
#include "cafPdmUiTreeSelectionEditor.h"
|
|
|
|
#include <tuple>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <iterator>
|
2017-11-06 15:23:54 -06:00
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
#include "RimWellLogPlotCollection.h"
|
|
|
|
#include "RigWellLogExtractor.h"
|
|
|
|
#include "RigEclipseWellLogExtractor.h"
|
|
|
|
#include "RigMainGrid.h"
|
|
|
|
#include "cafVecIjk.h"
|
|
|
|
#include "RigAccWellFlowCalculator.h"
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimWellPltPlot, "WellPltPlot");
|
|
|
|
|
2017-10-25 12:44:04 -05:00
|
|
|
namespace caf
|
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
template<>
|
|
|
|
void caf::AppEnum< RimWellPltPlot::FlowType>::setUp()
|
|
|
|
{
|
|
|
|
addItem(RimWellPltPlot::FLOW_TYPE_TOTAL, "TOTAL", "Total Flow");
|
|
|
|
addItem(RimWellPltPlot::FLOW_TYPE_PHASE_SPLIT, "PHASE_SPLIT", "Phase Split");
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void caf::AppEnum< RimWellPltPlot::FlowPhase>::setUp()
|
|
|
|
{
|
|
|
|
addItem(RimWellPltPlot::PHASE_OIL, "PHASE_OIL", "Oil");
|
|
|
|
addItem(RimWellPltPlot::PHASE_GAS, "PHASE_GAS", "Gas");
|
|
|
|
addItem(RimWellPltPlot::PHASE_WATER, "PHASE_WATER", "Water");
|
|
|
|
}
|
2017-10-25 12:44:04 -05:00
|
|
|
}
|
2017-10-25 07:43:17 -05:00
|
|
|
|
|
|
|
const QString RimWellPltPlot::OIL_CHANNEL_NAME = "QOZT";
|
|
|
|
const QString RimWellPltPlot::GAS_CHANNEL_NAME = "QGZT";
|
|
|
|
const QString RimWellPltPlot::WATER_CHANNEL_NAME = "QWZT";
|
|
|
|
const QString RimWellPltPlot::TOTAL_CHANNEL_NAME = "QTZT";
|
|
|
|
|
2017-10-23 06:57:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-25 07:43:17 -05:00
|
|
|
const std::set<QString> RimWellPltPlot::FLOW_DATA_NAMES = {
|
|
|
|
OIL_CHANNEL_NAME,
|
|
|
|
GAS_CHANNEL_NAME,
|
|
|
|
WATER_CHANNEL_NAME,
|
|
|
|
TOTAL_CHANNEL_NAME };
|
2017-10-27 02:17:05 -05:00
|
|
|
const char RimWellPltPlot::PLOT_NAME_QFORMAT_STRING[] = "PLT: %1";
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellPltPlot::RimWellPltPlot()
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("Well Allocation Plot", ":/WellAllocPlot16x16.png", "", "");
|
|
|
|
|
2017-10-27 02:17:05 -05:00
|
|
|
CAF_PDM_InitField(&m_userName, "PlotDescription", QString("PLT Plot"), "Name", "", "", "");
|
2017-10-23 06:57:01 -05:00
|
|
|
m_userName.uiCapability()->setUiReadOnly(true);
|
|
|
|
|
|
|
|
CAF_PDM_InitField(&m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_wellLogPlot, "WellLog", "WellLog", "", "", "");
|
|
|
|
m_wellLogPlot.uiCapability()->setUiHidden(true);
|
|
|
|
m_wellLogPlot = new RimWellLogPlot();
|
2017-10-25 07:43:17 -05:00
|
|
|
m_wellLogPlot->setDepthType(RimWellLogPlot::MEASURED_DEPTH);
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_wellName, "WellName", "WellName", "", "", "");
|
2017-10-25 07:43:17 -05:00
|
|
|
CAF_PDM_InitField(&m_branchIndex, "BranchIndex", 0, "BranchIndex", "", "", "");
|
2017-10-23 06:57:01 -05:00
|
|
|
|
2017-10-27 02:38:24 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_selectedSources, "SourcesInternal", "SourcesInternal", "", "", "");
|
2017-10-23 06:57:01 -05:00
|
|
|
m_selectedSources.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
|
|
|
|
m_selectedSources.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
|
|
|
m_selectedSources.uiCapability()->setAutoAddingOptionFromValue(false);
|
2017-10-27 02:38:24 -05:00
|
|
|
m_selectedSources.xmlCapability()->disableIO();
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_selectedSourcesForIo, "Sources", "Sources", "", "", "");
|
|
|
|
m_selectedSourcesForIo.uiCapability()->setUiHidden(true);
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_selectedTimeSteps, "TimeSteps", "TimeSteps", "", "", "");
|
|
|
|
m_selectedTimeSteps.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
|
|
|
|
m_selectedTimeSteps.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
|
|
|
m_selectedTimeSteps.uiCapability()->setAutoAddingOptionFromValue(false);
|
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_phaseSelectionMode, "PhaseSelectionMode", "Mode", "", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_phases, "Phases", "Phases", "", "", "");
|
|
|
|
m_phases.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
|
2017-10-27 02:38:24 -05:00
|
|
|
m_phases = std::vector<caf::AppEnum<FlowPhase>>({ FlowPhase::PHASE_OIL, FlowPhase::PHASE_GAS, FlowPhase::PHASE_WATER });
|
2017-10-25 07:43:17 -05:00
|
|
|
|
2017-10-23 06:57:01 -05:00
|
|
|
this->setAsPlotMdiWindow();
|
2017-10-27 02:38:24 -05:00
|
|
|
m_doInitAfterLoad = false;
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellPltPlot::~RimWellPltPlot()
|
|
|
|
{
|
|
|
|
removeMdiWindowFromMdiArea();
|
|
|
|
|
|
|
|
deleteViewWidget();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::deleteViewWidget()
|
|
|
|
{
|
|
|
|
if (m_wellLogPlotWidget)
|
|
|
|
{
|
|
|
|
m_wellLogPlotWidget->deleteLater();
|
|
|
|
m_wellLogPlotWidget = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-25 07:43:17 -05:00
|
|
|
//void RimWellPltPlot::applyCurveAppearance(RimWellLogCurve* newCurve)
|
|
|
|
//{
|
2017-10-26 03:35:23 -05:00
|
|
|
// const std::pair<RifWellRftAddress, QDateTime>& newCurveDef = curveDefFromCurve(newCurve);
|
2017-10-25 07:43:17 -05:00
|
|
|
//
|
|
|
|
// std::vector<cvf::Color3f> colorTable;
|
|
|
|
// RiaColorTables::summaryCurveDefaultPaletteColors().color3fArray().toStdVector(&colorTable);
|
|
|
|
//
|
|
|
|
// std::vector<RimPlotCurve::PointSymbolEnum> symbolTable =
|
|
|
|
// {
|
|
|
|
// RimPlotCurve::SYMBOL_ELLIPSE,
|
|
|
|
// RimPlotCurve::SYMBOL_RECT,
|
|
|
|
// RimPlotCurve::SYMBOL_DIAMOND,
|
|
|
|
// RimPlotCurve::SYMBOL_TRIANGLE,
|
|
|
|
// RimPlotCurve::SYMBOL_CROSS,
|
|
|
|
// RimPlotCurve::SYMBOL_XCROSS
|
|
|
|
// };
|
|
|
|
//
|
|
|
|
// // State variables
|
|
|
|
// static size_t defaultColorTableIndex = 0;
|
|
|
|
// static size_t defaultSymbolTableIndex = 0;
|
|
|
|
//
|
|
|
|
// cvf::Color3f currentColor;
|
|
|
|
// RimPlotCurve::PointSymbolEnum currentSymbol = symbolTable.front();
|
|
|
|
// RimPlotCurve::LineStyleEnum currentLineStyle = RimPlotCurve::STYLE_SOLID;
|
|
|
|
// bool isCurrentColorSet = false;
|
|
|
|
// bool isCurrentSymbolSet = false;
|
|
|
|
//
|
|
|
|
// std::set<cvf::Color3f> assignedColors;
|
|
|
|
// std::set<RimPlotCurve::PointSymbolEnum> assignedSymbols;
|
|
|
|
//
|
|
|
|
// // Used colors and symbols
|
|
|
|
// for (RimWellLogCurve* const curve : m_wellLogPlot->trackByIndex(0)->curvesVector())
|
|
|
|
// {
|
|
|
|
// if (curve == newCurve) continue;
|
|
|
|
//
|
2017-10-26 03:35:23 -05:00
|
|
|
// std::pair<RifWellRftAddress, QDateTime> cDef = curveDefFromCurve(curve);
|
2017-10-25 07:43:17 -05:00
|
|
|
// if (cDef.first == newCurveDef.first)
|
|
|
|
// {
|
|
|
|
// currentColor = curve->color();
|
|
|
|
// isCurrentColorSet = true;
|
|
|
|
// }
|
|
|
|
// if (cDef.second == newCurveDef.second)
|
|
|
|
// {
|
|
|
|
// currentSymbol = curve->symbol();
|
|
|
|
// isCurrentSymbolSet = true;
|
|
|
|
// }
|
|
|
|
// assignedColors.insert(curve->color());
|
|
|
|
// assignedSymbols.insert(curve->symbol());
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // Assign color
|
|
|
|
// if (!isCurrentColorSet)
|
|
|
|
// {
|
|
|
|
// for(const auto& color : colorTable)
|
|
|
|
// {
|
|
|
|
// if (assignedColors.count(color) == 0)
|
|
|
|
// {
|
|
|
|
// currentColor = color;
|
|
|
|
// isCurrentColorSet = true;
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (!isCurrentColorSet)
|
|
|
|
// {
|
|
|
|
// currentColor = colorTable[defaultColorTableIndex];
|
|
|
|
// if (++defaultColorTableIndex == colorTable.size())
|
|
|
|
// defaultColorTableIndex = 0;
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // Assign symbol
|
|
|
|
// if (!isCurrentSymbolSet)
|
|
|
|
// {
|
|
|
|
// for (const auto& symbol : symbolTable)
|
|
|
|
// {
|
|
|
|
// if (assignedSymbols.count(symbol) == 0)
|
|
|
|
// {
|
|
|
|
// currentSymbol = symbol;
|
|
|
|
// isCurrentSymbolSet = true;
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (!isCurrentSymbolSet)
|
|
|
|
// {
|
|
|
|
// currentSymbol = symbolTable[defaultSymbolTableIndex];
|
|
|
|
// if (++defaultSymbolTableIndex == symbolTable.size())
|
|
|
|
// defaultSymbolTableIndex = 0;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // Observed data
|
|
|
|
// currentLineStyle = newCurveDef.first.sourceType() == RftSourceType::OBSERVED
|
|
|
|
// ? RimPlotCurve::STYLE_NONE : RimPlotCurve::STYLE_SOLID;
|
|
|
|
//
|
|
|
|
// newCurve->setColor(currentColor);
|
|
|
|
// newCurve->setSymbol(currentSymbol);
|
|
|
|
// newCurve->setLineStyle(currentLineStyle);
|
|
|
|
//}
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::updateSelectedTimeStepsFromSelectedSources()
|
|
|
|
{
|
|
|
|
std::vector<QDateTime> newTimeStepsSelections;
|
2017-10-27 02:38:24 -05:00
|
|
|
std::vector<RifWellRftAddress> selectedSourcesVector = m_selectedSources();
|
2017-10-26 03:35:23 -05:00
|
|
|
auto selectedSources = std::set<RifWellRftAddress>(selectedSourcesVector.begin(), selectedSourcesVector.end());
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
for (const QDateTime& timeStep : m_selectedTimeSteps())
|
|
|
|
{
|
|
|
|
if(m_timeStepsToAddresses.count(timeStep) > 0)
|
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
std::vector<RifWellRftAddress> intersectVector;
|
|
|
|
const std::set<RifWellRftAddress>& addresses = m_timeStepsToAddresses[timeStep];
|
2017-10-23 06:57:01 -05:00
|
|
|
std::set_intersection(selectedSources.begin(), selectedSources.end(),
|
|
|
|
addresses.begin(), addresses.end(), std::inserter(intersectVector, intersectVector.end()));
|
|
|
|
if(intersectVector.size() > 0)
|
|
|
|
{
|
|
|
|
newTimeStepsSelections.push_back(timeStep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_selectedTimeSteps = newTimeStepsSelections;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-25 07:43:17 -05:00
|
|
|
///
|
2017-10-23 06:57:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-25 07:43:17 -05:00
|
|
|
RimWellPltPlot::FlowPhase RimWellPltPlot::flowPhaseFromChannelName(const QString& channelName)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
if (QString::compare(channelName, OIL_CHANNEL_NAME, Qt::CaseInsensitive) == 0) return PHASE_OIL;
|
|
|
|
if (QString::compare(channelName, GAS_CHANNEL_NAME, Qt::CaseInsensitive) == 0) return PHASE_GAS;
|
|
|
|
if (QString::compare(channelName, WATER_CHANNEL_NAME, Qt::CaseInsensitive) == 0) return PHASE_WATER;
|
|
|
|
if (QString::compare(channelName, TOTAL_CHANNEL_NAME, Qt::CaseInsensitive) == 0) return PHASE_TOTAL;
|
|
|
|
return PHASE_NONE;
|
|
|
|
}
|
2017-10-23 06:57:01 -05:00
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::setPlotXAxisTitles(RimWellLogTrack* plotTrack)
|
|
|
|
{
|
|
|
|
std::vector<RimEclipseCase*> cases = eclipseCases();
|
2017-10-23 06:57:01 -05:00
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
RiaEclipseUnitTools::UnitSystem unitSet = !cases.empty() ?
|
|
|
|
cases.front()->eclipseCaseData()->unitsType() :
|
|
|
|
RiaEclipseUnitTools::UNITS_UNKNOWN;
|
2017-10-23 06:57:01 -05:00
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
QString unitText;
|
|
|
|
switch (unitSet)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
case RiaEclipseUnitTools::UNITS_METRIC:
|
|
|
|
unitText = "[Liquid Sm<sup>3</sup>/day], [Gas kSm<sup>3</sup>/day]";
|
|
|
|
break;
|
|
|
|
case RiaEclipseUnitTools::UNITS_FIELD:
|
|
|
|
unitText = "[Liquid BBL/day], [Gas BOE/day]";
|
|
|
|
break;
|
|
|
|
case RiaEclipseUnitTools::UNITS_LAB:
|
|
|
|
unitText = "[cm<sup>3</sup>/hr]";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
unitText = "(unknown unit)";
|
|
|
|
break;
|
2017-10-23 06:57:01 -05:00
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
}
|
|
|
|
plotTrack->setXAxisTitle("Surface Flow Rate " + unitText);
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-25 07:43:17 -05:00
|
|
|
std::vector<RimEclipseCase*> RimWellPltPlot::eclipseCases() const
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
std::vector<RimEclipseCase*> cases;
|
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
for (const auto& oilField : proj->oilFields)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
for (const auto& eclCase : oilField->analysisModels()->cases)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
cases.push_back(eclCase);
|
|
|
|
}
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
2017-10-25 07:43:17 -05:00
|
|
|
return cases;
|
|
|
|
}
|
2017-10-23 06:57:01 -05:00
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
//void RimWellPltPlot::applyInitialSelections()
|
|
|
|
//{
|
|
|
|
// std::vector<std::tuple<RimEclipseResultCase*, bool, bool>> eclCaseTuples = eclipseCasesForWell(m_wellName);
|
|
|
|
//
|
2017-10-26 03:35:23 -05:00
|
|
|
// std::vector<RifWellRftAddress> sourcesToSelect;
|
|
|
|
// std::map<QDateTime, std::set<RifWellRftAddress>> rftTimeStepsMap;
|
|
|
|
// std::map<QDateTime, std::set<RifWellRftAddress>> observedTimeStepsMap;
|
|
|
|
// std::map<QDateTime, std::set<RifWellRftAddress>> gridTimeStepsMap;
|
2017-10-25 07:43:17 -05:00
|
|
|
//
|
|
|
|
// for(RimEclipseResultCase* const rftCase : rftCasesFromEclipseCases(eclCaseTuples))
|
|
|
|
// {
|
2017-10-26 03:35:23 -05:00
|
|
|
// sourcesToSelect.push_back(RifWellRftAddress(RftSourceType::RFT, rftCase));
|
2017-10-25 07:43:17 -05:00
|
|
|
// addTimeStepsToMap(rftTimeStepsMap, timeStepsFromRftCase(rftCase));
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// for (RimEclipseResultCase* const gridCase : gridCasesFromEclipseCases(eclCaseTuples))
|
|
|
|
// {
|
2017-10-26 03:35:23 -05:00
|
|
|
// sourcesToSelect.push_back(RifWellRftAddress(RftSourceType::GRID, gridCase));
|
2017-10-25 07:43:17 -05:00
|
|
|
// addTimeStepsToMap(gridTimeStepsMap, timeStepsFromGridCase(gridCase));
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// std::vector<RimWellLogFile*> wellLogFiles = wellLogFilesContainingFlow(m_wellName);
|
|
|
|
// if(wellLogFiles.size() > 0)
|
|
|
|
// {
|
2017-10-26 03:35:23 -05:00
|
|
|
// sourcesToSelect.push_back(RifWellRftAddress(RftSourceType::OBSERVED));
|
2017-10-25 07:43:17 -05:00
|
|
|
// for (RimWellLogFile* const wellLogFile : wellLogFiles)
|
|
|
|
// {
|
|
|
|
// addTimeStepsToMap(observedTimeStepsMap, timeStepsFromWellLogFile(wellLogFile));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// m_selectedSources = sourcesToSelect;
|
|
|
|
//
|
|
|
|
// std::set<QDateTime> timeStepsToSelect;
|
2017-10-26 03:35:23 -05:00
|
|
|
// for (const std::pair<QDateTime, std::set<RifWellRftAddress>>& dateTimePair : rftTimeStepsMap)
|
2017-10-25 07:43:17 -05:00
|
|
|
// {
|
|
|
|
// timeStepsToSelect.insert(dateTimePair.first);
|
|
|
|
// }
|
2017-10-26 03:35:23 -05:00
|
|
|
// for (const std::pair<QDateTime, std::set<RifWellRftAddress>>& dateTimePair : observedTimeStepsMap)
|
2017-10-25 07:43:17 -05:00
|
|
|
// {
|
|
|
|
// timeStepsToSelect.insert(dateTimePair.first);
|
|
|
|
// }
|
|
|
|
// if (gridTimeStepsMap.size() > 0)
|
|
|
|
// timeStepsToSelect.insert((*gridTimeStepsMap.begin()).first);
|
|
|
|
//
|
|
|
|
// m_selectedTimeSteps = std::vector<QDateTime>(timeStepsToSelect.begin(), timeStepsToSelect.end());
|
|
|
|
//
|
|
|
|
// syncCurvesFromUiSelection();
|
|
|
|
//}
|
|
|
|
|
2017-10-23 06:57:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::updateWidgetTitleWindowTitle()
|
|
|
|
{
|
|
|
|
updateMdiWindowTitle();
|
|
|
|
|
|
|
|
if (m_wellLogPlotWidget)
|
|
|
|
{
|
|
|
|
if (m_showPlotTitle)
|
|
|
|
{
|
|
|
|
m_wellLogPlotWidget->showTitle(m_userName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_wellLogPlotWidget->hideTitle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-25 07:43:17 -05:00
|
|
|
std::vector<RimWellLogFile*> RimWellPltPlot::wellLogFilesContainingFlow(const QString& wellName) const
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
std::vector<RimWellLogFile*> wellLogFiles;
|
|
|
|
const RimProject* const project = RiaApplication::instance()->project();
|
|
|
|
|
|
|
|
for (const auto& oilField : project->oilFields)
|
|
|
|
{
|
|
|
|
auto wellPathsVector = std::vector<RimWellPath*>(oilField->wellPathCollection()->wellPaths.begin(), oilField->wellPathCollection()->wellPaths.end());
|
|
|
|
|
|
|
|
for (const auto& wellPath : wellPathsVector)
|
|
|
|
{
|
|
|
|
bool hasPressure = false;
|
|
|
|
const std::vector<RimWellLogFile*> files = wellPath->wellLogFiles();
|
|
|
|
|
|
|
|
for (RimWellLogFile* const file : files)
|
|
|
|
{
|
|
|
|
size_t timeStepCount = timeStepsFromWellLogFile(file).size();
|
|
|
|
|
|
|
|
if (timeStepCount == 0) continue;
|
|
|
|
if (QString::compare(file->wellName(), wellName) != 0) continue;
|
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
if (hasFlowData(file))
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
wellLogFiles.push_back(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return wellLogFiles;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-25 07:43:17 -05:00
|
|
|
std::vector<RimWellLogFileChannel*> RimWellPltPlot::getFlowChannelsFromWellFile(const RimWellLogFile* wellLogFile) const
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
std::vector<RimWellLogFileChannel*> channels;
|
2017-10-23 06:57:01 -05:00
|
|
|
if(wellLogFile != nullptr)
|
|
|
|
{
|
|
|
|
for (RimWellLogFileChannel* const channel : wellLogFile->wellLogChannels())
|
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
if (isFlowChannel(channel))
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
channels.push_back(channel);
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-25 07:43:17 -05:00
|
|
|
return channels;
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellPath* RimWellPltPlot::wellPathFromWellLogFile(const RimWellLogFile* wellLogFile) const
|
|
|
|
{
|
|
|
|
RimProject* const project = RiaApplication::instance()->project();
|
|
|
|
for (const auto& oilField : project->oilFields)
|
|
|
|
{
|
|
|
|
auto wellPaths = std::vector<RimWellPath*>(oilField->wellPathCollection()->wellPaths.begin(), oilField->wellPathCollection()->wellPaths.end());
|
|
|
|
|
|
|
|
for (const auto& wellPath : wellPaths)
|
|
|
|
{
|
|
|
|
for (RimWellLogFile* const file : wellPath->wellLogFiles())
|
|
|
|
{
|
|
|
|
if (file == wellLogFile)
|
|
|
|
{
|
|
|
|
return wellPath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-25 07:43:17 -05:00
|
|
|
//std::vector<std::tuple<RimEclipseResultCase*, bool/*hasPressure*/, bool /*hasRftData*/>>
|
|
|
|
//RimWellPltPlot::eclipseCasesForWell(const QString& wellName) const
|
|
|
|
//{
|
|
|
|
// std::vector<std::tuple<RimEclipseResultCase*, bool, bool>> cases;
|
|
|
|
// const RimProject* const project = RiaApplication::instance()->project();
|
|
|
|
//
|
|
|
|
// for (const auto& oilField : project->oilFields)
|
|
|
|
// {
|
|
|
|
// const RimEclipseCaseCollection* const eclCaseColl = oilField->analysisModels();
|
|
|
|
// for (RimEclipseCase* eCase : eclCaseColl->cases())
|
|
|
|
// {
|
|
|
|
// auto eclCase = dynamic_cast<RimEclipseResultCase*>(eCase);
|
|
|
|
// if (eclCase != nullptr)
|
|
|
|
// {
|
|
|
|
// RigEclipseCaseData* const eclipseCaseData = eclCase->eclipseCaseData();
|
|
|
|
// for (const cvf::ref<RigSimWellData>& wellResult : eclipseCaseData->wellResults())
|
|
|
|
// {
|
|
|
|
// if (QString::compare(wellResult->m_wellName, wellName) == 0)
|
|
|
|
// {
|
|
|
|
// bool hasPressure = hasPressureData(eclCase);
|
|
|
|
// bool hasRftData = eclCase->rftReader() != nullptr;
|
|
|
|
// cases.push_back(std::make_tuple(eclCase, hasPressure, hasRftData));
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return cases;
|
|
|
|
//}
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-25 07:43:17 -05:00
|
|
|
//std::vector<RimEclipseResultCase*>
|
|
|
|
//RimWellPltPlot::gridCasesFromEclipseCases(const std::vector<std::tuple<RimEclipseResultCase*, bool, bool>>& eclipseCasesTuple) const
|
|
|
|
//{
|
|
|
|
// std::vector<RimEclipseResultCase*> cases;
|
|
|
|
// for (const std::tuple<RimEclipseResultCase*, bool, bool>& eclCaseTuple : eclipseCasesTuple)
|
|
|
|
// {
|
|
|
|
// bool hasPressureData = std::get<1>(eclCaseTuple);
|
|
|
|
// size_t timeStepCount = timeStepsFromGridCase(std::get<0>(eclCaseTuple)).size();
|
|
|
|
// if (hasPressureData && timeStepCount > 0)
|
|
|
|
// {
|
|
|
|
// cases.push_back(std::get<0>(eclCaseTuple));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return cases;
|
|
|
|
//}
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-25 07:43:17 -05:00
|
|
|
//std::vector<RimEclipseResultCase*>
|
|
|
|
//RimWellPltPlot::rftCasesFromEclipseCases(const std::vector<std::tuple<RimEclipseResultCase*, bool, bool>>& eclipseCasesTuple) const
|
|
|
|
//{
|
|
|
|
// std::vector<RimEclipseResultCase*> cases;
|
|
|
|
// for (const std::tuple<RimEclipseResultCase*, bool, bool>& eclCaseTuple : eclipseCasesTuple)
|
|
|
|
// {
|
|
|
|
// bool hasRftData = std::get<2>(eclCaseTuple);
|
|
|
|
// size_t timeStepCount = timeStepsFromRftCase(std::get<0>(eclCaseTuple)).size();
|
|
|
|
// if (hasRftData && timeStepCount > 0)
|
|
|
|
// {
|
|
|
|
// cases.push_back(std::get<0>(eclCaseTuple));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return cases;
|
|
|
|
//}
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-26 03:35:23 -05:00
|
|
|
//std::map<QDateTime, std::set<RifWellRftAddress>> RimWellPltPlot::timeStepsFromRftCase(RimEclipseResultCase* rftCase) const
|
2017-10-25 07:43:17 -05:00
|
|
|
//{
|
2017-10-26 03:35:23 -05:00
|
|
|
// std::map<QDateTime, std::set<RifWellRftAddress>> timeStepsMap;
|
2017-10-25 07:43:17 -05:00
|
|
|
// RifReaderEclipseRft* const reader = rftCase->rftReader();
|
|
|
|
// if (reader != nullptr)
|
|
|
|
// {
|
|
|
|
// for (const QDateTime& timeStep : reader->availableTimeSteps(m_wellName, RifEclipseRftAddress::PRESSURE))
|
|
|
|
// {
|
|
|
|
// if (timeStepsMap.count(timeStep) == 0)
|
|
|
|
// {
|
2017-10-26 03:35:23 -05:00
|
|
|
// timeStepsMap.insert(std::make_pair(timeStep, std::set<RifWellRftAddress>()));
|
2017-10-25 07:43:17 -05:00
|
|
|
// }
|
2017-10-26 03:35:23 -05:00
|
|
|
// timeStepsMap[timeStep].insert(RifWellRftAddress(RftSourceType::RFT, rftCase));
|
2017-10-25 07:43:17 -05:00
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return timeStepsMap;
|
|
|
|
//}
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-26 03:35:23 -05:00
|
|
|
//std::map<QDateTime, std::set<RifWellRftAddress>> RimWellPltPlot::timeStepsFromGridCase(RimEclipseCase* gridCase) const
|
2017-10-25 07:43:17 -05:00
|
|
|
//{
|
|
|
|
// const RigEclipseCaseData* const eclipseCaseData = gridCase->eclipseCaseData();
|
|
|
|
// size_t resultIndex = eclipseCaseData != nullptr ?
|
|
|
|
// eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, PRESSURE_DATA_NAME) :
|
|
|
|
// cvf::UNDEFINED_SIZE_T;
|
|
|
|
//
|
2017-10-26 03:35:23 -05:00
|
|
|
// std::map<QDateTime, std::set<RifWellRftAddress>> timeStepsMap;
|
2017-10-25 07:43:17 -05:00
|
|
|
// if (resultIndex != cvf::UNDEFINED_SIZE_T)
|
|
|
|
// {
|
|
|
|
// for (const QDateTime& timeStep : eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->timeStepDates(resultIndex))
|
|
|
|
// {
|
|
|
|
// if (timeStepsMap.count(timeStep) == 0)
|
|
|
|
// {
|
2017-10-26 03:35:23 -05:00
|
|
|
// timeStepsMap.insert(std::make_pair(timeStep, std::set<RifWellRftAddress>()));
|
2017-10-25 07:43:17 -05:00
|
|
|
// }
|
2017-10-26 03:35:23 -05:00
|
|
|
// timeStepsMap[timeStep].insert(RifWellRftAddress(RftSourceType::GRID, gridCase));
|
2017-10-25 07:43:17 -05:00
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return timeStepsMap;
|
|
|
|
//}
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-26 03:35:23 -05:00
|
|
|
std::map<QDateTime, std::set<RifWellRftAddress> > RimWellPltPlot::timeStepsFromWellLogFile(RimWellLogFile* wellLogFile) const
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
std::map<QDateTime, std::set<RifWellRftAddress> > timeStepsMap;
|
2017-10-23 06:57:01 -05:00
|
|
|
|
2017-11-01 04:29:03 -05:00
|
|
|
QDateTime timeStep = wellLogFile->date();
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
if (timeStepsMap.count(timeStep) == 0)
|
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
timeStepsMap.insert(std::make_pair(timeStep, std::set<RifWellRftAddress>()));
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
2017-10-26 03:35:23 -05:00
|
|
|
timeStepsMap[timeStep].insert(RifWellRftAddress(RifWellRftAddress::OBSERVED, wellLogFile));
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
return timeStepsMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-26 03:35:23 -05:00
|
|
|
std::map<QDateTime, std::set<RifWellRftAddress>>
|
|
|
|
RimWellPltPlot::adjacentTimeSteps(const std::vector<std::pair<QDateTime, std::set<RifWellRftAddress>>>& allTimeSteps,
|
|
|
|
const std::pair<QDateTime, std::set<RifWellRftAddress>>& searchTimeStepPair)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
std::map<QDateTime, std::set<RifWellRftAddress>> timeStepsMap;
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
if (allTimeSteps.size() > 0)
|
|
|
|
{
|
|
|
|
auto itr = std::find_if(allTimeSteps.begin(), allTimeSteps.end(),
|
2017-10-26 03:35:23 -05:00
|
|
|
[searchTimeStepPair](const std::pair<QDateTime, std::set<RifWellRftAddress>>& dt)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
return dt.first > searchTimeStepPair.first;
|
|
|
|
});
|
|
|
|
|
|
|
|
auto itrEnd = itr != allTimeSteps.end() ? itr + 1 : itr;
|
|
|
|
|
|
|
|
for (itr = itrEnd - 1; itr != allTimeSteps.begin() && (*itr).first >= searchTimeStepPair.first; itr--);
|
|
|
|
auto itrFirst = itr;
|
|
|
|
|
|
|
|
timeStepsMap.insert(itrFirst, itrEnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add searched time step in case it is not included
|
|
|
|
addTimeStepToMap(timeStepsMap, searchTimeStepPair);
|
|
|
|
|
|
|
|
return timeStepsMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-26 03:35:23 -05:00
|
|
|
bool RimWellPltPlot::mapContainsTimeStep(const std::map<QDateTime, std::set<RifWellRftAddress>>& map, const QDateTime& timeStep)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
return std::find_if(map.begin(), map.end(), [timeStep](const std::pair<QDateTime, std::set<RifWellRftAddress>>& pair)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
return pair.first == timeStep;
|
|
|
|
}) != map.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-26 03:35:23 -05:00
|
|
|
std::set < std::pair<RifWellRftAddress, QDateTime>> RimWellPltPlot::selectedCurveDefs() const
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
std::set<std::pair<RifWellRftAddress, QDateTime>> curveDefs;
|
2017-10-25 07:43:17 -05:00
|
|
|
//const std::vector<std::tuple<RimEclipseResultCase*,bool,bool>>& eclipseCases = eclipseCasesForWell(m_wellName);
|
|
|
|
//const std::vector<RimEclipseResultCase*> rftCases = rftCasesFromEclipseCases(eclipseCases);
|
|
|
|
//const std::vector<RimEclipseResultCase*> gridCases = gridCasesFromEclipseCases(eclipseCases);
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
for (const QDateTime& timeStep : m_selectedTimeSteps())
|
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
for (const RifWellRftAddress& addr : selectedSources())
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
//if (addr.sourceType() == RftSourceType::RFT)
|
|
|
|
//{
|
|
|
|
// for (RimEclipseResultCase* const rftCase : rftCases)
|
|
|
|
// {
|
2017-10-26 03:35:23 -05:00
|
|
|
// const std::map<QDateTime, std::set<RifWellRftAddress>>& timeStepsMap = timeStepsFromRftCase(rftCase);
|
2017-10-25 07:43:17 -05:00
|
|
|
// if (mapContainsTimeStep(timeStepsMap , timeStep))
|
|
|
|
// {
|
|
|
|
// curveDefs.insert(std::make_pair(addr, timeStep));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//else if (addr.sourceType() == RftSourceType::GRID)
|
|
|
|
//{
|
|
|
|
// for (RimEclipseResultCase* const gridCase : gridCases)
|
|
|
|
// {
|
2017-10-26 03:35:23 -05:00
|
|
|
// const std::map<QDateTime, std::set<RifWellRftAddress>>& timeStepsMap = timeStepsFromGridCase(gridCase);
|
2017-10-25 07:43:17 -05:00
|
|
|
// if (mapContainsTimeStep(timeStepsMap, timeStep))
|
|
|
|
// {
|
|
|
|
// curveDefs.insert(std::make_pair(addr, timeStep));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//else
|
2017-10-26 03:35:23 -05:00
|
|
|
if (addr.sourceType() == RifWellRftAddress::OBSERVED)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
if (addr.wellLogFile() != nullptr)
|
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
const std::map<QDateTime, std::set<RifWellRftAddress>>& timeStepsMap = timeStepsFromWellLogFile(addr.wellLogFile());
|
2017-10-23 06:57:01 -05:00
|
|
|
if (mapContainsTimeStep(timeStepsMap, timeStep))
|
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
curveDefs.insert(std::make_pair(RifWellRftAddress(RifWellRftAddress::OBSERVED, addr.wellLogFile()), timeStep));
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return curveDefs;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-26 03:35:23 -05:00
|
|
|
std::set<std::pair<RifWellRftAddress, QDateTime>> RimWellPltPlot::curveDefsFromCurves() const
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
std::set<std::pair<RifWellRftAddress, QDateTime>> curveDefs;
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
RimWellLogTrack* const plotTrack = m_wellLogPlot->trackByIndex(0);
|
|
|
|
for (RimWellLogCurve* const curve : plotTrack->curvesVector())
|
|
|
|
{
|
|
|
|
curveDefs.insert(curveDefFromCurve(curve));
|
|
|
|
}
|
|
|
|
return curveDefs;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-26 03:35:23 -05:00
|
|
|
std::pair<RifWellRftAddress, QDateTime> RimWellPltPlot::curveDefFromCurve(const RimWellLogCurve* curve) const
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
const RimWellLogRftCurve* rftCurve = dynamic_cast<const RimWellLogRftCurve*>(curve);
|
|
|
|
const RimWellLogExtractionCurve* gridCurve = dynamic_cast<const RimWellLogExtractionCurve*>(curve);
|
|
|
|
const RimWellLogFileCurve* wellLogFileCurve = dynamic_cast<const RimWellLogFileCurve*>(curve);
|
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
//if (rftCurve != nullptr)
|
|
|
|
//{
|
|
|
|
// RimEclipseResultCase* rftCase = dynamic_cast<RimEclipseResultCase*>(rftCurve->eclipseResultCase());
|
|
|
|
// if (rftCase != nullptr)
|
|
|
|
// {
|
|
|
|
// const RifEclipseRftAddress rftAddress = rftCurve->rftAddress();
|
|
|
|
// const QDateTime timeStep = rftAddress.timeStep();
|
2017-10-26 03:35:23 -05:00
|
|
|
// return std::make_pair(RifWellRftAddress(RftSourceType::RFT, rftCase), timeStep);
|
2017-10-25 07:43:17 -05:00
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//else if (gridCurve != nullptr)
|
|
|
|
//{
|
|
|
|
// RimEclipseResultCase* gridCase = dynamic_cast<RimEclipseResultCase*>(gridCurve->rimCase());
|
|
|
|
// if (gridCase != nullptr)
|
|
|
|
// {
|
|
|
|
// size_t timeStepIndex = gridCurve->currentTimeStep();
|
2017-10-26 03:35:23 -05:00
|
|
|
// const std::map<QDateTime, std::set<RifWellRftAddress>>& timeStepsMap = timeStepsFromGridCase(gridCase);
|
|
|
|
// auto timeStepsVector = std::vector<std::pair<QDateTime, std::set<RifWellRftAddress>>>(
|
2017-10-25 07:43:17 -05:00
|
|
|
// timeStepsMap.begin(), timeStepsMap.end());
|
|
|
|
// if (timeStepIndex < timeStepsMap.size())
|
|
|
|
// {
|
2017-10-26 03:35:23 -05:00
|
|
|
// return std::make_pair(RifWellRftAddress(RftSourceType::GRID, gridCase),
|
2017-10-25 07:43:17 -05:00
|
|
|
// timeStepsVector[timeStepIndex].first);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
if (wellLogFileCurve != nullptr)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
const RimWellPath* const wellPath = wellLogFileCurve->wellPath();
|
|
|
|
RimWellLogFile* const wellLogFile = wellLogFileCurve->wellLogFile();
|
|
|
|
|
|
|
|
if (wellLogFile != nullptr)
|
|
|
|
{
|
2017-11-01 04:29:03 -05:00
|
|
|
const QDateTime date = wellLogFile->date();
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
if (date.isValid())
|
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
return std::make_pair(RifWellRftAddress(RifWellRftAddress::OBSERVED, wellLogFile), date);
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-26 03:35:23 -05:00
|
|
|
return std::make_pair(RifWellRftAddress(), QDateTime());
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
|
2017-11-06 15:23:54 -06:00
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class RigRftResultPointCalculator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RigRftResultPointCalculator(const QString& wellName,
|
|
|
|
RimEclipseResultCase* eclCase,
|
|
|
|
QDateTime m_timeStep)
|
|
|
|
{
|
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
RimWellPath* wellPath = proj->wellPathFromSimulationWell(wellName);
|
|
|
|
RimWellLogPlotCollection* wellLogCollection = proj->mainPlotCollection()->wellLogPlotCollection();
|
|
|
|
RigEclipseWellLogExtractor* eclExtractor = wellLogCollection->findOrCreateExtractor(wellPath, eclCase);
|
|
|
|
|
|
|
|
std::vector<CellIntersectionInfo> intersections = eclExtractor->intersectionInfo();
|
|
|
|
|
|
|
|
RifEclipseRftAddress gasRateAddress(wellName, m_timeStep, RifEclipseRftAddress::GRAT);
|
|
|
|
RifEclipseRftAddress oilRateAddress(wellName, m_timeStep, RifEclipseRftAddress::ORAT);
|
|
|
|
RifEclipseRftAddress watRateAddress(wellName, m_timeStep, RifEclipseRftAddress::WRAT);
|
|
|
|
|
|
|
|
std::vector<caf::VecIjk> rftIndices;
|
|
|
|
eclCase->rftReader()->cellIndices(gasRateAddress, &rftIndices);
|
|
|
|
if (rftIndices.empty()) eclCase->rftReader()->cellIndices(oilRateAddress, &rftIndices);
|
|
|
|
if (rftIndices.empty()) eclCase->rftReader()->cellIndices(watRateAddress, &rftIndices);
|
|
|
|
if (rftIndices.empty()) return;
|
|
|
|
|
|
|
|
std::vector<double> gasRates;
|
|
|
|
std::vector<double> oilRates;
|
|
|
|
std::vector<double> watRates;
|
|
|
|
eclCase->rftReader()->values(gasRateAddress, &gasRates);
|
|
|
|
eclCase->rftReader()->values(oilRateAddress, &oilRates);
|
|
|
|
eclCase->rftReader()->values(watRateAddress, &watRates);
|
|
|
|
|
|
|
|
std::map<size_t, size_t> globCellIdxToIdxInRftFile;
|
|
|
|
|
|
|
|
const RigMainGrid* mainGrid = eclExtractor->caseData()->mainGrid();
|
|
|
|
|
|
|
|
for (size_t rftCellIdx = 0; rftCellIdx < rftIndices.size(); rftCellIdx++)
|
|
|
|
{
|
|
|
|
caf::VecIjk ijkIndex = rftIndices[rftCellIdx];
|
|
|
|
size_t globalCellIndex = mainGrid->cellIndexFromIJK(ijkIndex.i(), ijkIndex.j(), ijkIndex.k());
|
|
|
|
globCellIdxToIdxInRftFile[globalCellIndex] = rftCellIdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t wpExIdx = 0; wpExIdx < intersections.size(); wpExIdx++)
|
|
|
|
{
|
|
|
|
size_t globCellIdx = intersections[wpExIdx].globCellIndex;
|
|
|
|
|
|
|
|
auto it = globCellIdxToIdxInRftFile.find(globCellIdx);
|
|
|
|
if (it == globCellIdxToIdxInRftFile.end()) continue;
|
|
|
|
|
|
|
|
m_pipeBranchCLCoords.push_back(intersections[wpExIdx].startPoint);
|
|
|
|
m_pipeBranchMeasuredDepths.push_back(intersections[wpExIdx].startMD);
|
|
|
|
|
|
|
|
m_pipeBranchCLCoords.push_back(intersections[wpExIdx].endPoint);
|
|
|
|
m_pipeBranchMeasuredDepths.push_back(intersections[wpExIdx].endMD);
|
|
|
|
|
|
|
|
RigWellResultPoint resPoint;
|
|
|
|
resPoint.m_gridIndex = 0; // Always main grod
|
|
|
|
resPoint.m_gridCellIndex = globCellIdx; // Shortcut, since we only have main grid results from RFT
|
|
|
|
|
|
|
|
resPoint.m_oilRate = gasRates[it->second];
|
|
|
|
resPoint.m_gasRate = oilRates[it->second];
|
|
|
|
resPoint.m_waterRate = watRates[it->second];
|
|
|
|
|
|
|
|
m_pipeBranchWellResultPoints.push_back(resPoint);
|
|
|
|
m_pipeBranchWellResultPoints.push_back(RigWellResultPoint()); // Invalid res point describing the "line" between the cells
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::vector <cvf::Vec3d>& pipeBranchCLCoords() { return m_pipeBranchCLCoords; }
|
|
|
|
const std::vector <RigWellResultPoint>& pipeBranchWellResultPoints() { return m_pipeBranchWellResultPoints; }
|
|
|
|
const std::vector <double>& pipeBranchMeasuredDepths() { return m_pipeBranchMeasuredDepths; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector <cvf::Vec3d> m_pipeBranchCLCoords;
|
|
|
|
std::vector <RigWellResultPoint> m_pipeBranchWellResultPoints;
|
|
|
|
std::vector <double> m_pipeBranchMeasuredDepths;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-10-23 06:57:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-31 06:49:14 -05:00
|
|
|
void RimWellPltPlot::syncCurvesFromUiSelection()
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-31 06:49:14 -05:00
|
|
|
RimWellLogTrack* plotTrack = m_wellLogPlot->trackByIndex(0);
|
|
|
|
const std::set<std::pair<RifWellRftAddress, QDateTime>>& curveDefs = selectedCurveDefs();
|
2017-10-23 06:57:01 -05:00
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
setPlotXAxisTitles(plotTrack);
|
|
|
|
|
|
|
|
// Delete existing curves
|
|
|
|
const auto& curves = plotTrack->curvesVector();
|
|
|
|
for (const auto& curve : curves)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
plotTrack->removeCurve(curve);
|
|
|
|
}
|
|
|
|
|
2017-10-27 08:17:24 -05:00
|
|
|
int curveGroupId = 0;
|
|
|
|
|
2017-11-06 15:23:54 -06:00
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
RimWellPath* wellPath = proj->wellPathFromSimulationWell(m_wellName());
|
|
|
|
RimWellLogPlotCollection* wellLogCollection = proj->mainPlotCollection()->wellLogPlotCollection();
|
|
|
|
|
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
// Add curves
|
2017-10-26 03:35:23 -05:00
|
|
|
for (const std::pair<RifWellRftAddress, QDateTime>& curveDefToAdd : curveDefs)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-27 08:17:24 -05:00
|
|
|
std::set<FlowPhase> selectedPhases = m_phaseSelectionMode == FLOW_TYPE_PHASE_SPLIT ?
|
|
|
|
std::set<FlowPhase>(m_phases().begin(), m_phases().end()) :
|
|
|
|
std::set<FlowPhase>({ PHASE_TOTAL });
|
|
|
|
|
2017-11-06 15:23:54 -06:00
|
|
|
if (curveDefToAdd.first.sourceType() == RifWellRftAddress::RFT)
|
|
|
|
{
|
|
|
|
RigRftResultPointCalculator resultPointCalc(m_wellName(),
|
|
|
|
dynamic_cast<RimEclipseResultCase*>(curveDefToAdd.first.eclCase()),
|
|
|
|
curveDefToAdd.second);
|
|
|
|
if ( resultPointCalc.pipeBranchCLCoords().size() )
|
|
|
|
{
|
|
|
|
|
|
|
|
RigAccWellFlowCalculator wfAccumulator(resultPointCalc.pipeBranchCLCoords(),
|
|
|
|
resultPointCalc.pipeBranchWellResultPoints(),
|
|
|
|
resultPointCalc.pipeBranchMeasuredDepths(),
|
|
|
|
0.0);
|
|
|
|
|
|
|
|
const std::vector<double>& depthValues = wfAccumulator.pseudoLengthFromTop(0);
|
|
|
|
std::vector<QString> tracerNames = wfAccumulator.tracerNames();
|
|
|
|
for ( const QString& tracerName: tracerNames )
|
|
|
|
{
|
|
|
|
const std::vector<double> accFlow = wfAccumulator.accumulatedTracerFlowPrPseudoLength(tracerName, 0);
|
|
|
|
addStackedCurve(tracerName, depthValues, accFlow, plotTrack, curveGroupId, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-25 07:43:17 -05:00
|
|
|
//else if (curveDefToAdd.first.sourceType() == RftSourceType::GRID)
|
|
|
|
//{
|
|
|
|
// auto curve = new RimWellLogExtractionCurve();
|
|
|
|
// plotTrack->addCurve(curve);
|
|
|
|
|
|
|
|
// cvf::Color3f curveColor = RiaColorTables::wellLogPlotPaletteColors().cycledColor3f(plotTrack->curveCount());
|
|
|
|
// curve->setColor(curveColor);
|
|
|
|
// curve->setFromSimulationWellName(m_wellName, m_branchIndex);
|
|
|
|
|
|
|
|
// // Fetch cases and time steps
|
|
|
|
// auto gridCase = curveDefToAdd.first.eclCase();
|
|
|
|
// if (gridCase != nullptr)
|
|
|
|
// {
|
|
|
|
// // Case
|
|
|
|
// curve->setCase(gridCase);
|
|
|
|
|
|
|
|
// // Result definition
|
|
|
|
// RimEclipseResultDefinition* resultDef = new RimEclipseResultDefinition();
|
|
|
|
// resultDef->setResultVariable(PRESSURE_DATA_NAME);
|
|
|
|
// curve->setEclipseResultDefinition(resultDef);
|
|
|
|
|
|
|
|
// // Time step
|
2017-10-26 03:35:23 -05:00
|
|
|
// const std::map<QDateTime, std::set<RifWellRftAddress>>& timeSteps = timeStepsFromGridCase(gridCase);
|
2017-10-25 07:43:17 -05:00
|
|
|
// auto currentTimeStepItr = std::find_if(timeSteps.begin(), timeSteps.end(),
|
2017-10-26 03:35:23 -05:00
|
|
|
// [curveDefToAdd](std::pair<QDateTime, std::set<RifWellRftAddress>> pair) {return pair.first == curveDefToAdd.second; });
|
2017-10-25 07:43:17 -05:00
|
|
|
// auto currentTimeStepIndex = std::distance(timeSteps.begin(), currentTimeStepItr);
|
|
|
|
// curve->setCurrentTimeStep(currentTimeStepIndex);
|
|
|
|
// curve->setZOrder(0);
|
|
|
|
|
|
|
|
// applyCurveAppearance(curve);
|
|
|
|
// curve->loadDataAndUpdate(false);
|
|
|
|
// }
|
|
|
|
//}
|
2017-11-06 15:23:54 -06:00
|
|
|
else
|
2017-10-26 03:35:23 -05:00
|
|
|
if (curveDefToAdd.first.sourceType() == RifWellRftAddress::OBSERVED)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
RimWellLogFile* const wellLogFile = curveDefToAdd.first.wellLogFile();
|
|
|
|
if(wellLogFile!= nullptr)
|
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
RigWellLogFile* rigWellLogFile = wellLogFile->wellLogFile();
|
|
|
|
|
|
|
|
if (rigWellLogFile != nullptr)
|
|
|
|
{
|
|
|
|
for (RimWellLogFileChannel* channel : getFlowChannelsFromWellFile(wellLogFile))
|
|
|
|
{
|
|
|
|
const auto& channelName = channel->name();
|
|
|
|
if (selectedPhases.count(flowPhaseFromChannelName(channelName)) > 0)
|
|
|
|
{
|
2017-11-06 15:23:54 -06:00
|
|
|
addStackedCurve(channelName,
|
|
|
|
rigWellLogFile->depthValues(),
|
|
|
|
rigWellLogFile->values(channelName),
|
|
|
|
plotTrack,
|
|
|
|
curveGroupId,
|
|
|
|
true);
|
2017-10-25 07:43:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
}
|
2017-10-27 08:17:24 -05:00
|
|
|
curveGroupId++;
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::addStackedCurve(const QString& channelName,
|
|
|
|
const std::vector<double>& depthValues,
|
|
|
|
const std::vector<double>& accFlow,
|
2017-10-27 08:17:24 -05:00
|
|
|
RimWellLogTrack* plotTrack,
|
2017-10-27 08:49:00 -05:00
|
|
|
int curveGroupId,
|
|
|
|
bool doFillCurve)
|
2017-10-25 07:43:17 -05:00
|
|
|
{
|
|
|
|
RimWellFlowRateCurve* curve = new RimWellFlowRateCurve;
|
|
|
|
curve->setFlowValuesPrDepthValue(channelName, depthValues, accFlow);
|
|
|
|
|
|
|
|
auto color = channelName == OIL_CHANNEL_NAME ? cvf::Color3f::DARK_GREEN :
|
|
|
|
channelName == GAS_CHANNEL_NAME ? cvf::Color3f::DARK_RED :
|
|
|
|
channelName == WATER_CHANNEL_NAME ? cvf::Color3f::BLUE :
|
|
|
|
cvf::Color3f::DARK_GRAY;
|
2017-10-27 08:17:24 -05:00
|
|
|
curve->setColor(color);
|
|
|
|
curve->setGroupId(curveGroupId);
|
2017-10-27 08:49:00 -05:00
|
|
|
curve->setDoFillCurve(doFillCurve);
|
2017-10-25 07:43:17 -05:00
|
|
|
plotTrack->addCurve(curve);
|
|
|
|
|
|
|
|
curve->loadDataAndUpdate(true);
|
|
|
|
}
|
|
|
|
|
2017-10-23 06:57:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimWellPltPlot::isOnlyGridSourcesSelected() const
|
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
const std::vector<RifWellRftAddress>& selSources = m_selectedSources();
|
|
|
|
return std::find_if(selSources.begin(), selSources.end(), [](const RifWellRftAddress& addr)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
return addr.sourceType() == RifWellRftAddress::RFT || addr.sourceType() == RifWellRftAddress::OBSERVED;
|
2017-10-23 06:57:01 -05:00
|
|
|
}) == selSources.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-26 03:35:23 -05:00
|
|
|
bool RimWellPltPlot::isAnySourceAddressSelected(const std::set<RifWellRftAddress>& addresses) const
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
const std::vector<RifWellRftAddress>& selectedSourcesVector = m_selectedSources();
|
|
|
|
const auto selectedSources = std::set<RifWellRftAddress>(selectedSourcesVector.begin(), selectedSourcesVector.end());
|
|
|
|
std::vector<RifWellRftAddress> intersectVector;
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
std::set_intersection(selectedSources.begin(), selectedSources.end(),
|
|
|
|
addresses.begin(), addresses.end(), std::inserter(intersectVector, intersectVector.end()));
|
|
|
|
return intersectVector.size() > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-26 03:35:23 -05:00
|
|
|
std::vector<RifWellRftAddress> RimWellPltPlot::selectedSources() const
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
std::vector<RifWellRftAddress> sources;
|
|
|
|
for (const RifWellRftAddress& addr : m_selectedSources())
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
if (addr.sourceType() == RifWellRftAddress::OBSERVED)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
for (RimWellLogFile* const wellLogFile : wellLogFilesContainingFlow(m_wellName))
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
sources.push_back(RifWellRftAddress(RifWellRftAddress::OBSERVED, wellLogFile));
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sources.push_back(addr);
|
|
|
|
}
|
|
|
|
return sources;
|
|
|
|
}
|
|
|
|
|
2017-10-27 02:38:24 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RifWellRftAddress> RimWellPltPlot::selectedSourcesAndTimeSteps() const
|
|
|
|
{
|
|
|
|
std::vector<RifWellRftAddress> sources;
|
|
|
|
for (const RifWellRftAddress& addr : m_selectedSources())
|
|
|
|
{
|
|
|
|
if (addr.sourceType() == RifWellRftAddress::OBSERVED)
|
|
|
|
{
|
|
|
|
for (const QDateTime& timeStep : m_selectedTimeSteps())
|
|
|
|
{
|
|
|
|
for (const RifWellRftAddress& address : m_timeStepsToAddresses.at(timeStep))
|
|
|
|
{
|
|
|
|
sources.push_back(address);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sources.push_back(addr);
|
|
|
|
}
|
|
|
|
return sources;
|
|
|
|
}
|
|
|
|
|
2017-10-23 06:57:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QWidget* RimWellPltPlot::viewWidget()
|
|
|
|
{
|
|
|
|
return m_wellLogPlotWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::zoomAll()
|
|
|
|
{
|
|
|
|
m_wellLogPlot()->zoomAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellLogPlot* RimWellPltPlot::wellLogPlot() const
|
|
|
|
{
|
|
|
|
return m_wellLogPlot();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::setCurrentWellName(const QString& currWellName)
|
|
|
|
{
|
|
|
|
m_wellName = currWellName;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimWellPltPlot::currentWellName() const
|
|
|
|
{
|
|
|
|
return m_wellName;
|
|
|
|
}
|
|
|
|
|
2017-11-05 04:27:51 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
int RimWellPltPlot::branchIndex() const
|
|
|
|
{
|
|
|
|
return m_branchIndex;
|
|
|
|
}
|
|
|
|
|
2017-10-23 06:57:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-25 07:43:17 -05:00
|
|
|
bool RimWellPltPlot::hasFlowData(const RimWellLogFile* wellLogFile)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
for (RimWellLogFileChannel* const wellLogChannel : wellLogFile->wellLogChannels())
|
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
if (isFlowChannel(wellLogChannel)) return true;
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-25 07:43:17 -05:00
|
|
|
bool RimWellPltPlot::hasFlowData(RimWellPath* wellPath)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
for (RimWellLogFile* const wellLogFile : wellPath->wellLogFiles())
|
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
if (hasFlowData(wellLogFile))
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-25 07:43:17 -05:00
|
|
|
bool RimWellPltPlot::isFlowChannel(RimWellLogFileChannel* channel)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
return FLOW_DATA_NAMES.count(channel->name()) > 0;
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-25 07:43:17 -05:00
|
|
|
bool RimWellPltPlot::hasFlowData(RimEclipseResultCase* gridCase)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
const RigEclipseCaseData* const eclipseCaseData = gridCase->eclipseCaseData();
|
2017-10-25 07:43:17 -05:00
|
|
|
|
|
|
|
for (const QString& channelName : FLOW_DATA_NAMES)
|
|
|
|
{
|
|
|
|
size_t resultIndex = eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->
|
|
|
|
findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, channelName);
|
|
|
|
|
|
|
|
if (resultIndex != cvf::UNDEFINED_SIZE_T) return true;
|
|
|
|
}
|
|
|
|
return false;
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
const char* RimWellPltPlot::plotNameFormatString()
|
|
|
|
{
|
|
|
|
return PLOT_NAME_QFORMAT_STRING;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QList<caf::PdmOptionItemInfo> RimWellPltPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
|
|
|
|
if (fieldNeedingOptions == &m_wellName)
|
|
|
|
{
|
|
|
|
calculateValueOptionsForWells(options);
|
|
|
|
}
|
|
|
|
else if (fieldNeedingOptions == &m_selectedSources)
|
|
|
|
{
|
2017-10-31 09:41:28 -05:00
|
|
|
std::set<RifWellRftAddress> optionAddresses;
|
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
//const std::vector<std::tuple<RimEclipseResultCase*, bool, bool>>& eclipseCases = eclipseCasesForWell(m_wellName);
|
|
|
|
|
|
|
|
//const std::vector<RimEclipseResultCase*> rftCases = rftCasesFromEclipseCases(eclipseCases);
|
|
|
|
//if (rftCases.size() > 0)
|
|
|
|
//{
|
2017-10-26 03:35:23 -05:00
|
|
|
// options.push_back(caf::PdmOptionItemInfo::createHeader(RifWellRftAddress::sourceTypeUiText(RftSourceType::RFT), true));
|
2017-10-25 07:43:17 -05:00
|
|
|
//}
|
|
|
|
//for (const auto& rftCase : rftCases)
|
|
|
|
//{
|
2017-10-26 03:35:23 -05:00
|
|
|
// auto addr = RifWellRftAddress(RftSourceType::RFT, rftCase);
|
2017-10-25 07:43:17 -05:00
|
|
|
// auto item = caf::PdmOptionItemInfo(rftCase->caseUserDescription(), QVariant::fromValue(addr));
|
|
|
|
// item.setLevel(1);
|
|
|
|
// options.push_back(item);
|
|
|
|
//}
|
|
|
|
|
|
|
|
//const std::vector<RimEclipseResultCase*> gridCases = gridCasesFromEclipseCases(eclipseCases);
|
|
|
|
//if (gridCases.size() > 0)
|
|
|
|
//{
|
2017-10-26 03:35:23 -05:00
|
|
|
// options.push_back(caf::PdmOptionItemInfo::createHeader(RifWellRftAddress::sourceTypeUiText(RftSourceType::GRID), true));
|
2017-10-25 07:43:17 -05:00
|
|
|
//}
|
|
|
|
//for (const auto& gridCase : gridCases)
|
|
|
|
//{
|
2017-10-26 03:35:23 -05:00
|
|
|
// auto addr = RifWellRftAddress(RftSourceType::GRID, gridCase);
|
2017-10-25 07:43:17 -05:00
|
|
|
// auto item = caf::PdmOptionItemInfo(gridCase->caseUserDescription(), QVariant::fromValue(addr));
|
|
|
|
// item.setLevel(1);
|
|
|
|
// options.push_back(item);
|
|
|
|
//}
|
|
|
|
|
|
|
|
if (wellLogFilesContainingFlow(m_wellName).size() > 0)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
options.push_back(caf::PdmOptionItemInfo::createHeader(RifWellRftAddress::sourceTypeUiText(RifWellRftAddress::OBSERVED), true));
|
2017-10-23 06:57:01 -05:00
|
|
|
|
2017-10-26 03:35:23 -05:00
|
|
|
auto addr = RifWellRftAddress(RifWellRftAddress::OBSERVED);
|
2017-10-23 06:57:01 -05:00
|
|
|
auto item = caf::PdmOptionItemInfo("Observed Data", QVariant::fromValue(addr));
|
|
|
|
item.setLevel(1);
|
|
|
|
options.push_back(item);
|
2017-10-31 09:41:28 -05:00
|
|
|
optionAddresses.insert(addr);
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (fieldNeedingOptions == &m_selectedTimeSteps)
|
|
|
|
{
|
|
|
|
calculateValueOptionsForTimeSteps(m_wellName, options);
|
|
|
|
}
|
|
|
|
else if (fieldNeedingOptions == &m_branchIndex)
|
|
|
|
{
|
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
|
|
|
|
size_t branchCount = proj->simulationWellBranches(m_wellName).size();
|
|
|
|
|
|
|
|
for (int bIdx = 0; bIdx < static_cast<int>(branchCount); ++bIdx)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo("Branch " + QString::number(bIdx + 1), QVariant::fromValue(bIdx)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.size() == 0)
|
|
|
|
{
|
|
|
|
options.push_front(caf::PdmOptionItemInfo("None", -1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
if (fieldNeedingOptions == &m_phaseSelectionMode)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else if (fieldNeedingOptions == &m_phases)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo("Oil", PHASE_OIL));
|
|
|
|
options.push_back(caf::PdmOptionItemInfo("Gas", PHASE_GAS));
|
|
|
|
options.push_back(caf::PdmOptionItemInfo("Water", PHASE_WATER));
|
|
|
|
}
|
|
|
|
|
2017-10-23 06:57:01 -05:00
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
|
|
|
RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue);
|
|
|
|
|
|
|
|
if (changedField == &m_wellName)
|
|
|
|
{
|
|
|
|
setDescription(QString(plotNameFormatString()).arg(m_wellName));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changedField == &m_wellName || changedField == &m_branchIndex)
|
|
|
|
{
|
|
|
|
RimWellLogTrack* const plotTrack = m_wellLogPlot->trackByIndex(0);
|
|
|
|
for (RimWellLogCurve* const curve : plotTrack->curvesVector())
|
|
|
|
{
|
|
|
|
plotTrack->removeCurve(curve);
|
|
|
|
}
|
|
|
|
m_timeStepsToAddresses.clear();
|
|
|
|
}
|
|
|
|
else if (changedField == &m_selectedSources)
|
|
|
|
{
|
|
|
|
// Update time steps selections based on source selections
|
|
|
|
updateSelectedTimeStepsFromSelectedSources();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changedField == &m_selectedSources ||
|
|
|
|
changedField == &m_selectedTimeSteps)
|
|
|
|
{
|
2017-10-31 09:41:28 -05:00
|
|
|
syncSourcesIoFieldFromGuiField();
|
2017-10-23 06:57:01 -05:00
|
|
|
syncCurvesFromUiSelection();
|
|
|
|
}
|
|
|
|
else if (changedField == &m_showPlotTitle)
|
|
|
|
{
|
|
|
|
//m_wellLogPlot->setShowDescription(m_showPlotTitle);
|
|
|
|
}
|
2017-10-25 07:43:17 -05:00
|
|
|
|
|
|
|
if (changedField == &m_phaseSelectionMode ||
|
|
|
|
changedField == &m_phases)
|
|
|
|
{
|
|
|
|
syncCurvesFromUiSelection();
|
|
|
|
}
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QImage RimWellPltPlot::snapshotWindowContent()
|
|
|
|
{
|
|
|
|
QImage image;
|
|
|
|
|
|
|
|
if (m_wellLogPlotWidget)
|
|
|
|
{
|
|
|
|
QPixmap pix = QPixmap::grabWidget(m_wellLogPlotWidget);
|
|
|
|
image = pix.toImage();
|
|
|
|
}
|
|
|
|
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
|
|
{
|
|
|
|
uiOrdering.add(&m_userName);
|
|
|
|
uiOrdering.add(&m_wellName);
|
|
|
|
|
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
if (proj->simulationWellBranches(m_wellName).size() > 1)
|
|
|
|
{
|
|
|
|
uiOrdering.add(&m_branchIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
caf::PdmUiGroup* sourcesGroup = uiOrdering.addNewGroupWithKeyword("Sources", "Sources");
|
|
|
|
sourcesGroup->add(&m_selectedSources);
|
|
|
|
|
|
|
|
caf::PdmUiGroup* timeStepsGroup = uiOrdering.addNewGroupWithKeyword("Time Steps", "TimeSteps");
|
|
|
|
timeStepsGroup->add(&m_selectedTimeSteps);
|
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
caf::PdmUiGroup* flowGroup = uiOrdering.addNewGroupWithKeyword("Phase Selection", "PhaseSelection");
|
|
|
|
flowGroup->add(&m_phaseSelectionMode);
|
|
|
|
|
|
|
|
if (m_phaseSelectionMode == FLOW_TYPE_PHASE_SPLIT)
|
|
|
|
{
|
|
|
|
flowGroup->add(&m_phases);
|
|
|
|
}
|
|
|
|
|
2017-10-23 06:57:01 -05:00
|
|
|
//uiOrdering.add(&m_showPlotTitle);
|
|
|
|
|
|
|
|
uiOrdering.skipRemainingFields(true);
|
|
|
|
}
|
|
|
|
|
2017-10-25 07:43:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
|
|
|
{
|
|
|
|
if (field == &m_phases)
|
|
|
|
{
|
|
|
|
caf::PdmUiTreeSelectionEditorAttribute* attrib = dynamic_cast<caf::PdmUiTreeSelectionEditorAttribute*> (attribute);
|
|
|
|
attrib->showTextFilter = false;
|
|
|
|
attrib->showToggleAllCheckbox = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-27 02:38:24 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::initAfterRead()
|
|
|
|
{
|
|
|
|
RimViewWindow::initAfterRead();
|
|
|
|
|
|
|
|
// Postpone init until data has been loaded
|
|
|
|
m_doInitAfterLoad = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::setupBeforeSave()
|
|
|
|
{
|
2017-10-31 09:41:28 -05:00
|
|
|
syncCurvesFromUiSelection();
|
2017-10-27 02:38:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::initAfterLoad()
|
|
|
|
{
|
|
|
|
std::set<RifWellRftAddress> selectedSources;
|
|
|
|
for (RimRftAddress* addr : m_selectedSourcesForIo)
|
|
|
|
{
|
|
|
|
if (addr->address().sourceType() == RifWellRftAddress::OBSERVED)
|
|
|
|
{
|
|
|
|
selectedSources.insert(RifWellRftAddress(RifWellRftAddress::OBSERVED));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
selectedSources.insert(addr->address());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_selectedSources = std::vector<RifWellRftAddress>(selectedSources.begin(), selectedSources.end());
|
|
|
|
}
|
|
|
|
|
2017-10-31 09:41:28 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::syncSourcesIoFieldFromGuiField()
|
|
|
|
{
|
|
|
|
m_selectedSourcesForIo.clear();
|
|
|
|
for (const RifWellRftAddress& addr : selectedSourcesAndTimeSteps())
|
|
|
|
{
|
|
|
|
m_selectedSourcesForIo.push_back(new RimRftAddress(addr));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-23 06:57:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-26 03:35:23 -05:00
|
|
|
void RimWellPltPlot::addTimeStepToMap(std::map<QDateTime, std::set<RifWellRftAddress>>& destMap,
|
|
|
|
const std::pair<QDateTime, std::set<RifWellRftAddress>>& timeStepToAdd)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
auto timeStepMapToAdd = std::map<QDateTime, std::set<RifWellRftAddress>> { timeStepToAdd };
|
2017-10-23 06:57:01 -05:00
|
|
|
addTimeStepsToMap(destMap, timeStepMapToAdd);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-26 03:35:23 -05:00
|
|
|
void RimWellPltPlot::addTimeStepsToMap(std::map<QDateTime, std::set<RifWellRftAddress>>& destMap,
|
|
|
|
const std::map<QDateTime, std::set<RifWellRftAddress>>& timeStepsToAdd)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
for (const auto& timeStepPair : timeStepsToAdd)
|
|
|
|
{
|
|
|
|
if (timeStepPair.first.isValid())
|
|
|
|
{
|
|
|
|
if (destMap.count(timeStepPair.first) == 0)
|
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
destMap.insert(std::make_pair(timeStepPair.first, std::set<RifWellRftAddress>()));
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
auto addresses = timeStepPair.second;
|
|
|
|
destMap[timeStepPair.first].insert(addresses.begin(), addresses.end());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-31 09:41:28 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::updateTimeStepsToAddresses(const std::vector<RifWellRftAddress>& addressesToKeep)
|
|
|
|
{
|
|
|
|
for (auto& timeStepPair : m_timeStepsToAddresses)
|
|
|
|
{
|
|
|
|
std::vector<RifWellRftAddress> addressesToDelete;
|
|
|
|
std::set<RifWellRftAddress> keepAddresses = std::set<RifWellRftAddress>(addressesToKeep.begin(), addressesToKeep.end());
|
|
|
|
std::set<RifWellRftAddress>& currentAddresses = timeStepPair.second;
|
|
|
|
|
|
|
|
std::set_difference(currentAddresses.begin(), currentAddresses.end(),
|
|
|
|
keepAddresses.begin(), keepAddresses.end(),
|
|
|
|
std::inserter(addressesToDelete, addressesToDelete.end()));
|
|
|
|
|
|
|
|
for (const auto& addr : addressesToDelete)
|
|
|
|
{
|
|
|
|
currentAddresses.erase(addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-23 06:57:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::calculateValueOptionsForWells(QList<caf::PdmOptionItemInfo>& options)
|
|
|
|
{
|
|
|
|
RimProject * proj = RiaApplication::instance()->project();
|
|
|
|
|
|
|
|
if (proj != nullptr)
|
|
|
|
{
|
|
|
|
const std::vector<QString> simWellNames = proj->simulationWellNames();
|
|
|
|
auto wellNames = std::set<QString>(simWellNames.begin(), simWellNames.end());
|
|
|
|
|
|
|
|
// Observed wells
|
|
|
|
for (const auto& oilField : proj->oilFields())
|
|
|
|
{
|
|
|
|
auto wellPathColl = oilField->wellPathCollection();
|
|
|
|
for (const auto& wellPath : wellPathColl->wellPaths)
|
|
|
|
{
|
|
|
|
wellNames.insert(wellPath->name());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto& wellName : wellNames)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(wellName, wellName));
|
|
|
|
}
|
|
|
|
}
|
2017-11-06 07:20:43 -06:00
|
|
|
|
|
|
|
if (options.size() == 0)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo("None", "None"));
|
|
|
|
}
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::calculateValueOptionsForTimeSteps(const QString& wellName, QList<caf::PdmOptionItemInfo>& options)
|
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
std::map<QDateTime, std::set<RifWellRftAddress>> displayTimeStepsMap, obsAndRftTimeStepsMap, gridTimeStepsMap;
|
2017-10-25 07:43:17 -05:00
|
|
|
//const std::vector<std::tuple<RimEclipseResultCase*, bool, bool>>& eclipseCases = eclipseCasesForWell(wellName);
|
|
|
|
//const std::vector<RimEclipseResultCase*> rftCases = rftCasesFromEclipseCases(eclipseCases);
|
|
|
|
//const std::vector<RimEclipseResultCase*> gridCases = gridCasesFromEclipseCases(eclipseCases);
|
2017-10-23 06:57:01 -05:00
|
|
|
|
2017-10-31 09:41:28 -05:00
|
|
|
// First update timeSteps to Address 'cache'
|
|
|
|
std::vector<RifWellRftAddress> selSources = selectedSources();
|
|
|
|
updateTimeStepsToAddresses(selectedSources());
|
|
|
|
|
|
|
|
for (const RifWellRftAddress& selection : selSources)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-25 07:43:17 -05:00
|
|
|
//if (selection.sourceType() == RftSourceType::RFT)
|
|
|
|
//{
|
|
|
|
// for (RimEclipseResultCase* const rftCase : rftCases)
|
|
|
|
// {
|
|
|
|
// addTimeStepsToMap(obsAndRftTimeStepsMap, timeStepsFromRftCase(rftCase));
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//else if (selection.sourceType() == RftSourceType::GRID)
|
|
|
|
//{
|
|
|
|
// for (RimEclipseResultCase* const gridCase : gridCases)
|
|
|
|
// {
|
|
|
|
// addTimeStepsToMap(gridTimeStepsMap, timeStepsFromGridCase(gridCase));
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//else
|
2017-10-26 03:35:23 -05:00
|
|
|
if (selection.sourceType() == RifWellRftAddress::OBSERVED)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
if (selection.wellLogFile() != nullptr)
|
|
|
|
{
|
|
|
|
addTimeStepsToMap(obsAndRftTimeStepsMap, timeStepsFromWellLogFile(selection.wellLogFile()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isOnlyGridSourcesSelected())
|
|
|
|
{
|
|
|
|
displayTimeStepsMap = gridTimeStepsMap;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
const auto gridTimeStepsVector = std::vector<std::pair<QDateTime, std::set<RifWellRftAddress>>>(gridTimeStepsMap.begin(), gridTimeStepsMap.end());
|
2017-10-23 06:57:01 -05:00
|
|
|
|
2017-10-26 03:35:23 -05:00
|
|
|
for (const std::pair<QDateTime, std::set<RifWellRftAddress>>& timeStepPair : obsAndRftTimeStepsMap)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
const std::map<QDateTime, std::set<RifWellRftAddress>>& adjTimeSteps = adjacentTimeSteps(gridTimeStepsVector, timeStepPair);
|
2017-10-23 06:57:01 -05:00
|
|
|
addTimeStepsToMap(displayTimeStepsMap, adjTimeSteps);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the first grid time step (from the total grid time steps list)
|
|
|
|
if (gridTimeStepsVector.size() > 0)
|
|
|
|
{
|
|
|
|
addTimeStepToMap(displayTimeStepsMap, gridTimeStepsVector.front());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add already selected time steps
|
|
|
|
for (const QDateTime& timeStep : m_selectedTimeSteps())
|
|
|
|
{
|
|
|
|
if (m_timeStepsToAddresses.count(timeStep) > 0)
|
|
|
|
{
|
2017-10-26 03:35:23 -05:00
|
|
|
const std::set<RifWellRftAddress> sourceAddresses = m_timeStepsToAddresses[timeStep];
|
2017-10-23 06:57:01 -05:00
|
|
|
if (isAnySourceAddressSelected(sourceAddresses))
|
|
|
|
{
|
|
|
|
addTimeStepToMap(displayTimeStepsMap, std::make_pair(timeStep, m_timeStepsToAddresses[timeStep]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
addTimeStepsToMap(m_timeStepsToAddresses, displayTimeStepsMap);
|
|
|
|
|
|
|
|
// Create vector of all time steps
|
|
|
|
std::vector<QDateTime> allTimeSteps;
|
2017-10-26 03:35:23 -05:00
|
|
|
for (const std::pair<QDateTime, std::set<RifWellRftAddress>>& timeStepPair : m_timeStepsToAddresses)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
allTimeSteps.push_back(timeStepPair.first);
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString dateFormatString = RimTools::createTimeFormatStringFromDates(allTimeSteps);
|
2017-10-26 03:35:23 -05:00
|
|
|
for (const std::pair<QDateTime, std::set<RifWellRftAddress>>& timeStepPair : displayTimeStepsMap)
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(timeStepPair.first.toString(dateFormatString), timeStepPair.first));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPltPlot::setDescription(const QString& description)
|
|
|
|
{
|
|
|
|
m_userName = description;
|
|
|
|
|
|
|
|
updateWidgetTitleWindowTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimWellPltPlot::description() const
|
|
|
|
{
|
|
|
|
return m_userName();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-31 06:49:14 -05:00
|
|
|
void RimWellPltPlot::onLoadDataAndUpdate()
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2017-10-27 02:38:24 -05:00
|
|
|
if (m_doInitAfterLoad)
|
|
|
|
{
|
|
|
|
initAfterLoad();
|
|
|
|
m_doInitAfterLoad = false;
|
|
|
|
}
|
|
|
|
|
2017-10-23 06:57:01 -05:00
|
|
|
updateMdiWindowVisibility();
|
2017-10-27 02:38:24 -05:00
|
|
|
syncCurvesFromUiSelection();
|
2017-10-23 06:57:01 -05:00
|
|
|
m_wellLogPlot->loadDataAndUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QWidget* RimWellPltPlot::createViewWidget(QWidget* mainWindowParent)
|
|
|
|
{
|
|
|
|
m_wellLogPlotWidget = new RiuWellPltPlot(this, mainWindowParent);
|
|
|
|
return m_wellLogPlotWidget;
|
|
|
|
}
|