#4580 Import Eclipse RFT data as part of ensemble import

This commit is contained in:
Gaute Lindkvist committed 2019-08-26 11:56:36 +02:00
1 parent 222f230687
commit 71da659506
77 files changed
+2960 -848

No files matched your search

@@ -34,6 +34,7 @@ namespace caf
addItem(RifDataSourceForRftPlt::SourceType::RFT, "RFT", "RFT Cases");
addItem(RifDataSourceForRftPlt::SourceType::GRID, "GRID", "Grid Cases");
addItem(RifDataSourceForRftPlt::SourceType::OBSERVED, "OBSERVED", "Observed Data");
addItem(RifDataSourceForRftPlt::SourceType::ENSEMBLE_RFT, "ENSEMBLE", "Ensembles with RFT Data");
setDefault(RifDataSourceForRftPlt::SourceType::NONE);
}
}
@@ -32,6 +32,8 @@
#include "RimEclipseResultCase.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimWellLogExtractionCurve.h"
#include "RimWellLogFile.h"
#include "RimWellLogFileChannel.h"
@@ -406,6 +408,48 @@ std::vector<RimEclipseResultCase*> RimWellPlotTools::rftCasesForWell(const QStri
return cases;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimSummaryCaseCollection*> RimWellPlotTools::rftEnsemblesForWell(const QString& simWellName)
{
const RimProject* project = RiaApplication::instance()->project();
std::vector<RimSummaryCaseCollection*> allSummaryCaseCollections = project->summaryGroups();
std::vector<RimSummaryCaseCollection*> rftEnsembles;
for (RimSummaryCaseCollection* summaryCaseColl : allSummaryCaseCollections)
{
if (summaryCaseColl && summaryCaseColl->isEnsemble() && !summaryCaseColl->rftTimeStepsForWell(simWellName).empty())
{
rftEnsembles.push_back(summaryCaseColl);
}
}
return rftEnsembles;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimSummaryCaseCollection*> RimWellPlotTools::rftEnsembles()
{
const RimProject* project = RiaApplication::instance()->project();
std::vector<RimSummaryCaseCollection*> allSummaryCaseCollections = project->summaryGroups();
std::vector<RimSummaryCaseCollection*> rftEnsembles;
for (RimSummaryCaseCollection* summaryCaseColl : allSummaryCaseCollections)
{
if (summaryCaseColl && summaryCaseColl->isEnsemble() && !summaryCaseColl->wellsWithRftData().empty())
{
rftEnsembles.push_back(summaryCaseColl);
}
}
return rftEnsembles;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -495,12 +539,28 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve(const RimWellLogCur
if (rftCurve != nullptr)
{
RimEclipseResultCase* rftCase = dynamic_cast<RimEclipseResultCase*>(rftCurve->eclipseResultCase());
RimEclipseResultCase* rftCase = dynamic_cast<RimEclipseResultCase*>(rftCurve->eclipseResultCase());
RimSummaryCase* rftSummaryCase = rftCurve->summaryCase();
RimSummaryCaseCollection* rftEnsemble = rftCurve->ensemble();
const RifEclipseRftAddress rftAddress = rftCurve->rftAddress();
const QString& wellName = rftAddress.wellName();
const QDateTime& timeStep = rftAddress.timeStep();
if (rftCase != nullptr)
{
const RifEclipseRftAddress rftAddress = rftCurve->rftAddress();
const QDateTime timeStep = rftAddress.timeStep();
return RiaRftPltCurveDefinition(RifDataSourceForRftPlt(RifDataSourceForRftPlt::RFT, rftCase), timeStep);
return RiaRftPltCurveDefinition(RifDataSourceForRftPlt(RifDataSourceForRftPlt::RFT, rftCase), wellName, timeStep);
}
else if (rftSummaryCase != nullptr)
{
rftSummaryCase->firstAncestorOrThisOfTypeAsserted(rftEnsemble);
return RiaRftPltCurveDefinition(
RifDataSourceForRftPlt(RifDataSourceForRftPlt::SUMMARY_RFT, rftSummaryCase, rftEnsemble), wellName, timeStep);
}
else if (rftEnsemble != nullptr)
{
return RiaRftPltCurveDefinition(
RifDataSourceForRftPlt(RifDataSourceForRftPlt::ENSEMBLE_RFT, rftEnsemble), wellName, timeStep);
}
}
else if (gridCurve != nullptr)
@@ -515,6 +575,7 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve(const RimWellLogCur
if (timeStepIndex < timeStepsMap.size())
{
return RiaRftPltCurveDefinition(RifDataSourceForRftPlt(RifDataSourceForRftPlt::GRID, gridCase),
gridCurve->wellName(),
timeStepsVector[timeStepIndex].first);
}
}
@@ -529,11 +590,12 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve(const RimWellLogCur
if (date.isValid())
{
return RiaRftPltCurveDefinition(RifDataSourceForRftPlt(RifDataSourceForRftPlt::OBSERVED, wellLogFile), date);
return RiaRftPltCurveDefinition(
RifDataSourceForRftPlt(RifDataSourceForRftPlt::OBSERVED, wellLogFile), wellLogFile->wellName(), date);
}
}
}
return RiaRftPltCurveDefinition(RifDataSourceForRftPlt(), QDateTime());
return RiaRftPltCurveDefinition(RifDataSourceForRftPlt(), QString(), QDateTime());
}
//--------------------------------------------------------------------------------------------------
@@ -591,14 +653,14 @@ std::set<RiaRftPltCurveDefinition>
for (const RifDataSourceForRftPlt& addr : selectedSourcesExpanded)
{
if (addr.rftReader())
if (addr.sourceType() == RifDataSourceForRftPlt::RFT && addr.rftReader())
{
std::set<QDateTime> rftTimes = addr.rftReader()->availableTimeSteps(simWellName, interestingRFTResults);
for (const QDateTime& time : rftTimes)
{
if (selectedTimeStepSet.count(time))
{
curveDefs.insert(RiaRftPltCurveDefinition(addr, time));
curveDefs.insert(RiaRftPltCurveDefinition(addr, simWellName, time));
}
}
}
@@ -611,7 +673,7 @@ std::set<RiaRftPltCurveDefinition>
{
if (selectedTimeStepSet.count(time))
{
curveDefs.insert(RiaRftPltCurveDefinition(addr, time));
curveDefs.insert(RiaRftPltCurveDefinition(addr, simWellName, time));
}
}
}
@@ -621,7 +683,37 @@ std::set<RiaRftPltCurveDefinition>
{
if (selectedTimeStepSet.count(addr.wellLogFile()->date()))
{
curveDefs.insert(RiaRftPltCurveDefinition(addr, addr.wellLogFile()->date()));
curveDefs.insert(RiaRftPltCurveDefinition(addr, simWellName, addr.wellLogFile()->date()));
}
}
}
else if (addr.sourceType() == RifDataSourceForRftPlt::ENSEMBLE_RFT)
{
if (addr.ensemble())
{
for (RimSummaryCase* summaryCase : addr.ensemble()->allSummaryCases())
{
if (summaryCase && summaryCase->rftReader())
{
RifDataSourceForRftPlt summaryAddr(RifDataSourceForRftPlt::SUMMARY_RFT, summaryCase, addr.ensemble());
std::set<QDateTime> timeSteps = summaryCase->rftReader()->availableTimeSteps(simWellName);
for (const QDateTime& time : timeSteps)
{
if (selectedTimeStepSet.count(time))
{
curveDefs.insert(RiaRftPltCurveDefinition(summaryAddr, simWellName, time));
}
}
}
}
std::set<QDateTime> statTimeSteps = addr.ensemble()->rftTimeStepsForWell(simWellName);
for (const QDateTime& time : statTimeSteps)
{
if (selectedTimeStepSet.count(time))
{
curveDefs.insert(RiaRftPltCurveDefinition(addr, simWellName, time));
}
}
}
}
@@ -780,9 +872,11 @@ std::map<QDateTime, std::set<RifDataSourceForRftPlt>> RimWellPlotTools::calculat
{
bool addFirstTimestep = (interestingRFTResults.count(RifEclipseRftAddress::PRESSURE) == 1);
bool hasObservedData = false;
bool hasRftData = false;
bool hasGridData = false;
bool hasObservedData = false;
bool hasRftData = false;
bool hasGridData = false;
bool hasEnsembleData = false;
bool hasSummaryRftData = false;
for (const auto& source : selSources)
{
@@ -797,12 +891,20 @@ std::map<QDateTime, std::set<RifDataSourceForRftPlt>> RimWellPlotTools::calculat
case RifDataSourceForRftPlt::OBSERVED:
hasObservedData = true;
break;
case RifDataSourceForRftPlt::SUMMARY_RFT:
hasSummaryRftData = true;
break;
case RifDataSourceForRftPlt::ENSEMBLE_RFT:
hasEnsembleData = true;
break;
}
}
std::map<QDateTime, std::set<RifDataSourceForRftPlt>> observedTimeStepsWithSources;
std::map<QDateTime, std::set<RifDataSourceForRftPlt>> rftTimeStepsWithSources;
std::map<QDateTime, std::set<RifDataSourceForRftPlt>> gridTimestepsWithSources;
std::map<QDateTime, std::set<RifDataSourceForRftPlt>> summaryRftTimeStepsWithSources;
std::map<QDateTime, std::set<RifDataSourceForRftPlt>> ensembleTimeStepsWithSources;
if (hasObservedData)
{
@@ -848,6 +950,39 @@ std::map<QDateTime, std::set<RifDataSourceForRftPlt>> RimWellPlotTools::calculat
}
}
if (hasSummaryRftData)
{
for (const auto& source : selSources)
{
if (source.sourceType() == RifDataSourceForRftPlt::SUMMARY_RFT && source.summaryCase())
{
std::set<QDateTime> wellTimeSteps =
source.summaryCase()->rftReader()->availableTimeSteps(wellPathNameOrSimWellName);
for (const QDateTime& date : wellTimeSteps)
{
summaryRftTimeStepsWithSources[date].insert(source);
}
}
}
}
if (hasEnsembleData)
{
for (const auto& source : selSources)
{
if (source.sourceType() == RifDataSourceForRftPlt::ENSEMBLE_RFT && source.ensemble())
{
std::set<QDateTime> wellTimeSteps = source.ensemble()->rftTimeStepsForWell(wellPathNameOrSimWellName);
for (const QDateTime& date : wellTimeSteps)
{
ensembleTimeStepsWithSources[date].insert(source);
}
}
}
}
// If we have a time baseline add the equal or adjacent grid timesteps
std::map<QDateTime, std::set<RifDataSourceForRftPlt>> timestepsToShowWithSources;
@@ -861,6 +996,14 @@ std::map<QDateTime, std::set<RifDataSourceForRftPlt>> RimWellPlotTools::calculat
{
timeBaseline = &rftTimeStepsWithSources;
}
else if (hasSummaryRftData)
{
timeBaseline = &summaryRftTimeStepsWithSources;
}
else if (hasEnsembleData)
{
timeBaseline = &ensembleTimeStepsWithSources;
}
if (timeBaseline)
{
@@ -876,9 +1019,21 @@ std::map<QDateTime, std::set<RifDataSourceForRftPlt>> RimWellPlotTools::calculat
for (const auto& dateSourceSetPair : gridTimestepsWithSources)
gridTimeSteps.insert(dateSourceSetPair.first);
std::set<QDateTime> summaryRftTimeSteps;
for (const auto& dateSourceSetPair : summaryRftTimeStepsWithSources)
summaryRftTimeSteps.insert(dateSourceSetPair.first);
std::set<QDateTime> ensembleRftTimeSteps;
for (const auto& dateSourceSetPair : ensembleTimeStepsWithSources)
ensembleRftTimeSteps.insert(dateSourceSetPair.first);
std::set<QDateTime> filteredRftTimeSteps = RimWellPlotTools::findMatchingOrAdjacentTimeSteps(baseTimeSteps, rftTimeSteps);
std::set<QDateTime> filteredGridTimeSteps =
RimWellPlotTools::findMatchingOrAdjacentTimeSteps(baseTimeSteps, gridTimeSteps);
std::set<QDateTime> filteredSummaryRftTimeSteps =
RimWellPlotTools::findMatchingOrAdjacentTimeSteps(baseTimeSteps, summaryRftTimeSteps);
std::set<QDateTime> filteredEnsembleRftTimeSteps =
RimWellPlotTools::findMatchingOrAdjacentTimeSteps(baseTimeSteps, ensembleRftTimeSteps);
if (addFirstTimestep && gridTimeSteps.size())
{
@@ -889,6 +1044,7 @@ std::map<QDateTime, std::set<RifDataSourceForRftPlt>> RimWellPlotTools::calculat
timestepsToShowWithSources = observedTimeStepsWithSources;
std::set<QDateTime>& allFilteredTimesteps = filteredRftTimeSteps;
allFilteredTimesteps.insert(filteredEnsembleRftTimeSteps.begin(), filteredEnsembleRftTimeSteps.end());
allFilteredTimesteps.insert(filteredGridTimeSteps.begin(), filteredGridTimeSteps.end());
for (const QDateTime& time : allFilteredTimesteps)
@@ -900,11 +1056,25 @@ std::map<QDateTime, std::set<RifDataSourceForRftPlt>> RimWellPlotTools::calculat
timestepsToShowWithSources[time].insert(sourceSet.begin(), sourceSet.end());
}
auto gridTimeSourceSetIt = gridTimestepsWithSources.find(time);
auto gridTimeSourceSetIt = gridTimestepsWithSources.find(time);
if (gridTimeSourceSetIt != gridTimestepsWithSources.end())
{
std::set<RifDataSourceForRftPlt>& sourceSet = gridTimeSourceSetIt->second;
timestepsToShowWithSources[time].insert(sourceSet.begin(), sourceSet.end());
}
auto summaryRftTimeSourceSetIt = summaryRftTimeStepsWithSources.find(time);
if (summaryRftTimeSourceSetIt != summaryRftTimeStepsWithSources.end())
{
std::set<RifDataSourceForRftPlt>& sourceSet = summaryRftTimeSourceSetIt->second;
timestepsToShowWithSources[time].insert(sourceSet.begin(), sourceSet.end());
}
auto ensembleRftTimeSourceSetIt = ensembleTimeStepsWithSources.find(time);
if (ensembleRftTimeSourceSetIt != ensembleTimeStepsWithSources.end())
{
std::set<RifDataSourceForRftPlt>& sourceSet = ensembleRftTimeSourceSetIt->second;
timestepsToShowWithSources[time].insert(sourceSet.begin(), sourceSet.end());
}
}
}
@@ -943,9 +1113,10 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(
{
QString optionText = RiaQDateTimeTools::toStringUsingApplicationLocale(timeStepPair.first, dateFormatString);
bool hasObs = false;
bool hasRft = false;
bool hasGrid = false;
bool hasObs = false;
bool hasRft = false;
bool hasGrid = false;
bool hasEnsemble = false;
for (const auto& source : timeStepPair.second)
{
@@ -960,15 +1131,19 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(
case RifDataSourceForRftPlt::GRID:
hasGrid = true;
break;
case RifDataSourceForRftPlt::ENSEMBLE_RFT:
hasEnsemble = true;
break;
}
}
optionText += " \t[ ";
if (hasObs) optionText += "O ";
if (hasRft) optionText += "R ";
if (hasGrid) optionText += "G";
optionText += " ]";
QStringList optionTags;
if (hasObs) optionTags << "O";
if (hasRft) optionTags << "R";
if (hasGrid) optionTags << "G";
if (hasEnsemble) optionTags << "E";
optionText += QString(" \t[%1]").arg(optionTags.join(", "));
options.push_back(caf::PdmOptionItemInfo(optionText, timeStepPair.first));
}
}
@@ -33,6 +33,7 @@
class RimEclipseCase;
class RimEclipseResultCase;
class RimSummaryCaseCollection;
class RimWellLogCurve;
class RimWellLogFileChannel;
class RimWellLogPlot;
@@ -82,6 +83,8 @@ public:
// Both
static std::vector<RimEclipseResultCase*> gridCasesForWell(const QString& simWellName);
static std::vector<RimEclipseResultCase*> rftCasesForWell(const QString& simWellName);
static std::vector<RimSummaryCaseCollection*> rftEnsemblesForWell(const QString& simWellName);
static std::vector<RimSummaryCaseCollection*> rftEnsembles();
static QString simWellName(const QString& wellPathNameOrSimWellName);
static std::map<QDateTime, std::set<RifDataSourceForRftPlt>>
@@ -19,6 +19,7 @@
#include "RimWellRftPlot.h"
#include "RiaApplication.h"
#include "RiaColorTools.h"
#include "RiaColorTables.h"
#include "RiaDateStringParser.h"
#include "RiaSimWellBranchTools.h"
@@ -36,6 +37,7 @@
#include "RimEclipseResultDefinition.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSummaryCaseCollection.h"
#include "RimTools.h"
#include "RimWellLogExtractionCurve.h"
#include "RimWellLogFile.h"
@@ -49,6 +51,7 @@
#include "RimWellPlotTools.h"
#include "RimWellPltPlot.h"
#include "RiuWellLogTrack.h"
#include "RiuWellRftPlot.h"
#include "cafPdmUiTreeOrdering.h"
@@ -76,6 +79,8 @@ RimWellRftPlot::RimWellRftPlot()
m_userName.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitField(&m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "");
CAF_PDM_InitField(&m_showStatisticsCurves, "ShowStatisticsCurves", true, "Show Statistics Curves", "", "", "");
CAF_PDM_InitField(&m_showEnsembleCurves, "ShowEnsembleCurves", true, "Show Ensemble Curves", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellLogPlot, "WellLog", "Well Log", "", "", "");
m_wellLogPlot.uiCapability()->setUiHidden(true);
@@ -135,94 +140,39 @@ void RimWellRftPlot::deleteViewWidget()
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve)
{
const RiaRftPltCurveDefinition& newCurveDef = RimWellPlotTools::curveDefFromCurve(newCurve);
RiaRftPltCurveDefinition newCurveDef = RimWellPlotTools::curveDefFromCurve(newCurve);
std::vector<cvf::Color3f> colorTable;
RiaColorTables::summaryCurveDefaultPaletteColors().color3fArray().toStdVector(&colorTable);
RiuQwtPlotCurve::LineStyleEnum currentLineStyle = RiuQwtPlotCurve::STYLE_SOLID;
std::vector<RiuQwtSymbol::PointSymbolEnum> symbolTable = {RiuQwtSymbol::SYMBOL_ELLIPSE,
RiuQwtSymbol::SYMBOL_RECT,
RiuQwtSymbol::SYMBOL_DIAMOND,
RiuQwtSymbol::SYMBOL_TRIANGLE,
RiuQwtSymbol::SYMBOL_CROSS,
RiuQwtSymbol::SYMBOL_XCROSS};
// State variables
static size_t defaultColorTableIndex = 0;
static size_t defaultSymbolTableIndex = 0;
cvf::Color3f currentColor;
RiuQwtSymbol::PointSymbolEnum currentSymbol = symbolTable.front();
RiuQwtPlotCurve::LineStyleEnum currentLineStyle = RiuQwtPlotCurve::STYLE_SOLID;
bool isCurrentColorSet = false;
bool isCurrentSymbolSet = false;
std::set<cvf::Color3f> assignedColors;
std::set<RiuQwtSymbol::PointSymbolEnum> assignedSymbols;
// Used colors and symbols
for (RimWellLogCurve* const curve : m_wellLogPlot->trackByIndex(0)->curvesVector())
{
if (curve == newCurve) continue;
RiaRftPltCurveDefinition cDef = RimWellPlotTools::curveDefFromCurve(curve);
if (cDef.address() == newCurveDef.address())
{
currentColor = curve->color();
isCurrentColorSet = true;
}
if (cDef.timeStep() == newCurveDef.timeStep())
{
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;
}
}
cvf::Color3f currentColor;
if (newCurveDef.address().sourceType() == RifDataSourceForRftPlt::SUMMARY_RFT)
{
RifDataSourceForRftPlt sourceAddress(RifDataSourceForRftPlt::ENSEMBLE_RFT, newCurveDef.address().ensemble());
currentColor = m_dataSourceColors[sourceAddress];
if (m_showStatisticsCurves)
{
cvf::Color3f backgroundColor =
RiaColorTools::fromQColorTo3f(m_wellLogPlot->trackByIndex(0)->viewer()->canvasBackground().color());
currentColor = RiaColorTools::blendCvfColors(backgroundColor, currentColor, 2, 1);
}
}
else
{
currentColor = m_dataSourceColors[newCurveDef.address()];
}
RiuQwtSymbol::PointSymbolEnum currentSymbol = RiuQwtSymbol::SYMBOL_NONE;
if (newCurveDef.address().sourceType() != RifDataSourceForRftPlt::ENSEMBLE_RFT)
{
currentSymbol = m_timeStepSymbols[newCurveDef.timeStep()];
}
// Observed data
currentLineStyle = newCurveDef.address().sourceType() == RifDataSourceForRftPlt::OBSERVED ? RiuQwtPlotCurve::STYLE_NONE
: RiuQwtPlotCurve::STYLE_SOLID;
newCurve->setColor(currentColor);
newCurve->setSymbolEdgeColor(currentColor);
newCurve->setSymbol(currentSymbol);
newCurve->setLineStyle(currentLineStyle);
}
@@ -289,6 +239,11 @@ void RimWellRftPlot::applyInitialSelections()
sourcesToSelect.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::GRID, gridCase));
}
for (RimSummaryCaseCollection* const ensemble : RimWellPlotTools::rftEnsemblesForWell(simWellName))
{
sourcesToSelect.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::ENSEMBLE_RFT, ensemble));
}
std::vector<RimWellLogFile*> wellLogFiles = RimWellPlotTools::wellLogFilesContainingPressure(m_wellPathNameOrSimWellName);
if (!wellLogFiles.empty())
{
@@ -447,6 +402,8 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set<RiaRftPltCurveDefinition>
// Delete curves
plotTrack->deleteAllCurves();
defineCurveColorsAndSymbols(allCurveDefs);
// Add new curves
for (const RiaRftPltCurveDefinition& curveDefToAdd : allCurveDefs)
{
@@ -465,6 +422,47 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set<RiaRftPltCurveDefinition>
applyCurveAppearance(curve);
}
else if (m_showEnsembleCurves && curveDefToAdd.address().sourceType() == RifDataSourceForRftPlt::SUMMARY_RFT)
{
auto curve = new RimWellLogRftCurve();
plotTrack->addCurve(curve);
auto rftCase = curveDefToAdd.address().summaryCase();
curve->setSummaryCase(rftCase);
RifEclipseRftAddress address(simWellName, curveDefToAdd.timeStep(), RifEclipseRftAddress::PRESSURE);
curve->setRftAddress(address);
curve->setZOrder(1);
applyCurveAppearance(curve);
}
else if (m_showStatisticsCurves && curveDefToAdd.address().sourceType() == RifDataSourceForRftPlt::ENSEMBLE_RFT)
{
RimSummaryCaseCollection* ensemble = curveDefToAdd.address().ensemble();
std::set<RifEclipseRftAddress> rftAddresses =
ensemble->rftStatisticsReader()->eclipseRftAddresses(simWellName, curveDefToAdd.timeStep());
for (auto rftAddress : rftAddresses)
{
if (rftAddress.wellLogChannel() != RifEclipseRftAddress::TVD)
{
auto curve = new RimWellLogRftCurve();
plotTrack->addCurve(curve);
curve->setEnsemble(ensemble);
curve->setRftAddress(rftAddress);
curve->setZOrder(RiuQwtPlotCurve::Z_ENSEMBLE_STAT_CURVE);
applyCurveAppearance(curve);
auto symbol = statisticsCurveSymbolFromAddress(rftAddress);
RiuQwtSymbol::LabelPosition labelPos = statisticsLabelPosFromAddress(rftAddress);
curve->setSymbol(symbol);
curve->setSymbolLabelPosition(labelPos);
curve->setSymbolSize(curve->symbolSize() + 3);
curve->setSymbolSkipDistance(150);
curve->setLineStyle(RiuQwtPlotCurve::STYLE_SOLID);
QString uiText =
caf::AppEnum<RifEclipseRftAddress::RftWellLogChannelType>::uiText(rftAddress.wellLogChannel());
QString label = uiText.replace("Pressure", "");
curve->setSymbolLabel(label);
}
}
}
else if (curveDefToAdd.address().sourceType() == RifDataSourceForRftPlt::GRID)
{
auto curve = new RimWellLogExtractionCurve();
@@ -580,6 +578,14 @@ RimWellLogPlot* RimWellRftPlot::wellLogPlot() const
return m_wellLogPlot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QString& RimWellRftPlot::simWellOrWellPathName() const
{
return m_wellPathNameOrSimWellName.v();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -639,6 +645,21 @@ QList<caf::PdmOptionItemInfo> RimWellRftPlot::calculateValueOptions(const caf::P
}
}
const std::vector<RimSummaryCaseCollection*> rftEnsembles = RimWellPlotTools::rftEnsemblesForWell(simWellName);
if (!rftEnsembles.empty())
{
options.push_back(caf::PdmOptionItemInfo::createHeader(
RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::ENSEMBLE_RFT), true));
for (RimSummaryCaseCollection* rftEnsemble : rftEnsembles)
{
auto addr = RifDataSourceForRftPlt(RifDataSourceForRftPlt::ENSEMBLE_RFT, rftEnsemble);
auto item = caf::PdmOptionItemInfo(rftEnsemble->name(), QVariant::fromValue(addr));
item.setLevel(1);
options.push_back(item);
}
}
const std::vector<RimEclipseResultCase*> gridCases = RimWellPlotTools::gridCasesForWell(simWellName);
if (!gridCases.empty())
{
@@ -716,7 +737,14 @@ void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
{
updateFormationsOnPlot();
syncCurvesFromUiSelection();
this->updateConnectedEditors();
}
else if (changedField == &m_showStatisticsCurves || changedField == &m_showEnsembleCurves)
{
updateFormationsOnPlot();
syncCurvesFromUiSelection();
}
else if (changedField == &m_showPlotTitle)
{
// m_wellLogPlot->setShowDescription(m_showPlotTitle);
@@ -754,6 +782,20 @@ void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
{
uiOrdering.add(&m_userName);
uiOrdering.add(&m_wellPathNameOrSimWellName);
uiOrdering.add(&m_showStatisticsCurves);
uiOrdering.add(&m_showEnsembleCurves);
bool showingEnsembleData = false;
for (const RifDataSourceForRftPlt& dataSource : m_selectedSources())
{
if (dataSource.sourceType() == RifDataSourceForRftPlt::ENSEMBLE_RFT)
{
showingEnsembleData = true;
break;
}
}
m_showStatisticsCurves.uiCapability()->setUiReadOnly(!showingEnsembleData);
m_showEnsembleCurves.uiCapability()->setUiReadOnly(!showingEnsembleData);
RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromWellName(
&uiOrdering, m_wellPathNameOrSimWellName, m_branchDetection, m_branchIndex);
@@ -818,6 +860,20 @@ void RimWellRftPlot::calculateValueOptionsForWells(QList<caf::PdmOptionItemInfo>
}
}
// Ensemble RFT wells
const std::vector<RimSummaryCaseCollection*> rftEnsembles = RimWellPlotTools::rftEnsembles();
if (!rftEnsembles.empty())
{
for (RimSummaryCaseCollection* summaryCaseColl : rftEnsembles)
{
std::set<QString> wellsWithRftData = summaryCaseColl->wellsWithRftData();
for (QString wellName : wellsWithRftData)
{
wellNames.insert(std::make_pair(wellName, wellName));
}
}
}
for (const auto& wellName : wellNames)
{
options.push_back(caf::PdmOptionItemInfo(wellName.first, wellName.second));
@@ -870,6 +926,8 @@ void RimWellRftPlot::onLoadDataAndUpdate()
updateEditorsFromCurves();
updateWidgetTitleWindowTitle();
// applyInitialSelections();
}
//--------------------------------------------------------------------------------------------------
@@ -903,3 +961,88 @@ QWidget* RimWellRftPlot::createViewWidget(QWidget* mainWindowParent)
return m_wellLogPlotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::PointSymbolEnum RimWellRftPlot::statisticsCurveSymbolFromAddress(const RifEclipseRftAddress& address)
{
switch (address.wellLogChannel())
{
case RifEclipseRftAddress::PRESSURE_P10:
return RiuQwtSymbol::SYMBOL_TRIANGLE;
case RifEclipseRftAddress::PRESSURE_P50:
return RiuQwtSymbol::SYMBOL_DOWN_TRIANGLE;
case RifEclipseRftAddress::PRESSURE_P90:
return RiuQwtSymbol::SYMBOL_LEFT_TRIANGLE;
case RifEclipseRftAddress::PRESSURE_MEAN:
return RiuQwtSymbol::SYMBOL_RIGHT_TRIANGLE;
}
return RiuQwtSymbol::SYMBOL_RIGHT_TRIANGLE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtSymbol::LabelPosition RimWellRftPlot::statisticsLabelPosFromAddress(const RifEclipseRftAddress& address)
{
switch (address.wellLogChannel())
{
case RifEclipseRftAddress::PRESSURE_P10:
return RiuQwtSymbol::LabelLeftOfSymbol;
case RifEclipseRftAddress::PRESSURE_P50:
return RiuQwtSymbol::LabelAboveSymbol;
case RifEclipseRftAddress::PRESSURE_P90:
return RiuQwtSymbol::LabelRightOfSymbol;
case RifEclipseRftAddress::PRESSURE_MEAN:
return RiuQwtSymbol::LabelBelowSymbol;
}
return RiuQwtSymbol::LabelAboveSymbol;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::defineCurveColorsAndSymbols(const std::set<RiaRftPltCurveDefinition>& allCurveDefs)
{
m_dataSourceColors.clear();
m_timeStepSymbols.clear();
std::vector<cvf::Color3f> colorTable;
RiaColorTables::summaryCurveDefaultPaletteColors().color3fArray().toStdVector(&colorTable);
std::vector<RiuQwtSymbol::PointSymbolEnum> symbolTable = {RiuQwtSymbol::SYMBOL_ELLIPSE,
RiuQwtSymbol::SYMBOL_RECT,
RiuQwtSymbol::SYMBOL_DIAMOND,
RiuQwtSymbol::SYMBOL_CROSS,
RiuQwtSymbol::SYMBOL_XCROSS,
RiuQwtSymbol::SYMBOL_STAR1};
// Add new curves
for (const RiaRftPltCurveDefinition& curveDefToAdd : allCurveDefs)
{
auto colorTableIndex = m_dataSourceColors.size();
auto symbolTableIndex = m_timeStepSymbols.size();
RifDataSourceForRftPlt address = curveDefToAdd.address();
if (address.sourceType() != RifDataSourceForRftPlt::SUMMARY_RFT)
{
if (!m_dataSourceColors.count(curveDefToAdd.address()))
{
colorTableIndex = colorTableIndex % colorTable.size();
m_dataSourceColors[curveDefToAdd.address()] = colorTable[colorTableIndex];
}
}
if (address.sourceType() != RifDataSourceForRftPlt::ENSEMBLE_RFT)
{
if (!m_timeStepSymbols.count(curveDefToAdd.timeStep()))
{
symbolTableIndex = symbolTableIndex % symbolTable.size();
m_timeStepSymbols[curveDefToAdd.timeStep()] = symbolTable[symbolTableIndex];
}
}
}
}
@@ -1,27 +1,27 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimViewWindow.h"
#include "RifDataSourceForRftPltQMetaType.h"
#include "RiuQwtSymbol.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
@@ -46,102 +46,118 @@ class RiuWellRftPlot;
class RigEclipseCaseData;
class RiaRftPltCurveDefinition;
class RifDataSourceForRftPlt;
class RifEclipseRftAddress;
namespace cvf {
class Color3f;
namespace cvf
{
class Color3f;
}
namespace caf {
class PdmOptionItemInfo;
namespace caf
{
class PdmOptionItemInfo;
}
//==================================================================================================
///
///
///
///
//==================================================================================================
class RimWellRftPlot : public RimViewWindow
{
CAF_PDM_HEADER_INIT;
static const std::set<QString> PRESSURE_DATA_NAMES;
static const char PLOT_NAME_QFORMAT_STRING[];
static const char PLOT_NAME_QFORMAT_STRING[];
public:
RimWellRftPlot();
~RimWellRftPlot() override;
void setDescription(const QString& description);
QString description() const;
void setDescription(const QString& description);
QString description() const;
QWidget* viewWidget() override;
void zoomAll() override;
QWidget* viewWidget() override;
void zoomAll() override;
RimWellLogPlot* wellLogPlot() const;
RimWellLogPlot* wellLogPlot() const;
void setSimWellOrWellPathName(const QString& currWellName);
const QString& simWellOrWellPathName() const;
void setSimWellOrWellPathName(const QString& currWellName);
int branchIndex() const;
int branchIndex() const;
void applyInitialSelections();
void applyInitialSelections();
static const char* plotNameFormatString();
protected:
// Overridden PDM methods
caf::PdmFieldHandle* userDescriptionField() override { return &m_userName; }
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override;
caf::PdmFieldHandle* userDescriptionField() override
{
return &m_userName;
}
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly) override;
QImage snapshotWindowContent() override;
QImage snapshotWindowContent() override;
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
void onLoadDataAndUpdate() override;
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
void onLoadDataAndUpdate() override;
private:
void calculateValueOptionsForWells(QList<caf::PdmOptionItemInfo>& options);
void updateEditorsFromCurves();
void updateWidgetTitleWindowTitle();
void syncCurvesFromUiSelection();
void assignWellPathToExtractionCurves();
void calculateValueOptionsForWells(QList<caf::PdmOptionItemInfo>& options);
void updateEditorsFromCurves();
void updateWidgetTitleWindowTitle();
void syncCurvesFromUiSelection();
void assignWellPathToExtractionCurves();
std::set<RiaRftPltCurveDefinition> selectedCurveDefs() const;
std::set<RiaRftPltCurveDefinition> curveDefsFromCurves() const;
std::set<RiaRftPltCurveDefinition> selectedCurveDefs() const;
std::set<RiaRftPltCurveDefinition> curveDefsFromCurves() const;
void updateCurvesInPlot(const std::set<RiaRftPltCurveDefinition>& allCurveDefs,
const std::set<RiaRftPltCurveDefinition>& curveDefsToAdd,
const std::set<RimWellLogCurve*>& curvesToDelete);
void updateCurvesInPlot(const std::set<RiaRftPltCurveDefinition>& allCurveDefs,
const std::set<RiaRftPltCurveDefinition>& curveDefsToAdd,
const std::set<RimWellLogCurve*>& curvesToDelete);
std::vector<RifDataSourceForRftPlt> selectedSourcesExpanded() const;
// RimViewWindow overrides
QWidget* createViewWidget(QWidget* mainWindowParent) override;
void deleteViewWidget() override;
QWidget* createViewWidget(QWidget* mainWindowParent) override;
void deleteViewWidget() override;
void applyCurveAppearance(RimWellLogCurve* newCurve);
void applyCurveAppearance(RimWellLogCurve* newCurve);
void updateFormationsOnPlot() const;
QString associatedSimWellName() const;
void updateFormationsOnPlot() const;
QString associatedSimWellName() const;
static RiuQwtSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress(const RifEclipseRftAddress& address);
static RiuQwtSymbol::LabelPosition statisticsLabelPosFromAddress(const RifEclipseRftAddress& address);
void defineCurveColorsAndSymbols(const std::set<RiaRftPltCurveDefinition>& allCurveDefs);
private:
caf::PdmField<bool> m_showPlotTitle;
caf::PdmField<QString> m_userName;
caf::PdmField<bool> m_showPlotTitle;
caf::PdmField<QString> m_userName;
caf::PdmField<QString> m_wellPathNameOrSimWellName;
caf::PdmField<int> m_branchIndex;
caf::PdmField<bool> m_branchDetection;
caf::PdmField<QString> m_wellPathNameOrSimWellName;
caf::PdmField<int> m_branchIndex;
caf::PdmField<bool> m_branchDetection;
caf::PdmField<bool> m_showStatisticsCurves;
caf::PdmField<bool> m_showEnsembleCurves;
caf::PdmField<std::vector<RifDataSourceForRftPlt>> m_selectedSources;
caf::PdmField<std::vector<QDateTime>> m_selectedTimeSteps;
caf::PdmField<std::vector<RifDataSourceForRftPlt>> m_selectedSources;
caf::PdmChildField<RimWellLogPlot*> m_wellLogPlot;
caf::PdmField<std::vector<QDateTime>> m_selectedTimeSteps;
QPointer<RiuWellRftPlot> m_wellLogPlotWidget;
caf::PdmChildField<RimWellLogPlot*> m_wellLogPlot;
QPointer<RiuWellRftPlot> m_wellLogPlotWidget;
std::map<RifDataSourceForRftPlt, cvf::Color3f> m_dataSourceColors;
std::map<QDateTime, RiuQwtSymbol::PointSymbolEnum> m_timeStepSymbols;
bool m_isOnLoad;
};
@@ -191,7 +191,7 @@ QList<caf::PdmOptionItemInfo> Rim3dWellLogRftCurve::calculateValueOptions(const
if (reader)
{
QString dateFormat = "dd MMM yyyy";
std::vector<QDateTime> timeStamps = reader->availableTimeSteps(wellName(), m_wellLogChannelName());
std::set<QDateTime> timeStamps = reader->availableTimeSteps(wellName(), m_wellLogChannelName());
for (const QDateTime& dt : timeStamps)
{
QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale(dt, dateFormat);
@@ -73,12 +73,27 @@ void RimPlotCurve::PointSymbol::setUp()
addItem(RiuQwtSymbol::SYMBOL_RECT, "SYMBOL_RECT", "Rect");
addItem(RiuQwtSymbol::SYMBOL_DIAMOND, "SYMBOL_DIAMOND", "Diamond");
addItem(RiuQwtSymbol::SYMBOL_TRIANGLE, "SYMBOL_TRIANGLE", "Triangle");
addItem(RiuQwtSymbol::SYMBOL_DOWN_TRIANGLE, "SYMBOL_DOWN_TRIANGLE", "Down Triangle");
addItem(RiuQwtSymbol::SYMBOL_CROSS, "SYMBOL_CROSS", "Cross");
addItem(RiuQwtSymbol::SYMBOL_XCROSS, "SYMBOL_XCROSS", "X Cross");
addItem(RiuQwtSymbol::SYMBOL_STAR1, "SYMBOL_STAR1", "Star 1");
addItem(RiuQwtSymbol::SYMBOL_STAR2, "SYMBOL_STAR2", "Star 2");
addItem(RiuQwtSymbol::SYMBOL_HEXAGON, "SYMBOL_HEXAGON", "Hexagon");
addItem(RiuQwtSymbol::SYMBOL_LEFT_TRIANGLE, "SYMBOL_LEFT_TRIANGLE", "Left Triangle");
addItem(RiuQwtSymbol::SYMBOL_RIGHT_TRIANGLE, "SYMBOL_RIGHT_TRIANGLE", "Right Triangle");
setDefault(RiuQwtSymbol::SYMBOL_NONE);
}
template<>
void RimPlotCurve::LabelPosition::setUp()
{
addItem(RiuQwtSymbol::LabelAboveSymbol, "LABEL_ABOVE_SYMBOL", "Label above Symbol");
addItem(RiuQwtSymbol::LabelBelowSymbol, "LABEL_BELOW_SYMBOL", "Label below Symbol");
addItem(RiuQwtSymbol::LabelLeftOfSymbol, "LABEL_LEFT_OF_SYMBOL", "Label left of Symbol");
addItem(RiuQwtSymbol::LabelRightOfSymbol, "LABEL_RIGHT_OF_SYMBOL", "Label right of Symbol");
setDefault(RiuQwtSymbol::LabelAboveSymbol);
}
}
@@ -86,7 +101,6 @@ void RimPlotCurve::PointSymbol::setUp()
///
//--------------------------------------------------------------------------------------------------
RimPlotCurve::RimPlotCurve()
: m_symbolLabelPosition(RiuQwtSymbol::LabelAboveSymbol)
{
CAF_PDM_InitObject("Curve", ":/WellLogCurve16x16.png", "", "");
@@ -116,10 +130,13 @@ RimPlotCurve::RimPlotCurve()
CAF_PDM_InitField(&m_showLegend, "ShowLegend", true, "Contribute To Legend", "", "", "");
CAF_PDM_InitField(&m_symbolSize, "SymbolSize", 6, "Symbol Size", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_symbolLabel, "SymbolLabel", "Symbol Label", "", "", "");
CAF_PDM_InitField(&m_symbolSize, "SymbolSize", 6, "Symbol Size", "", "", "");
CAF_PDM_InitField(&m_showErrorBars, "ShowErrorBars", true, "Show Error Bars", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_symbolLabelPosition, "SymbolLabelPosition", "Symbol Label Position", "", "", "");
m_qwtPlotCurve = new RiuRimQwtPlotCurve(this);
m_parentQwtPlot = nullptr;
@@ -548,7 +565,7 @@ void RimPlotCurve::updateCurveAppearance()
if (m_pointSymbol() != RiuQwtSymbol::SYMBOL_NONE)
{
// QwtPlotCurve will take ownership of the symbol
symbol = new RiuQwtSymbol(m_pointSymbol(), m_symbolLabel, m_symbolLabelPosition);
symbol = new RiuQwtSymbol(m_pointSymbol(), m_symbolLabel(), m_symbolLabelPosition());
symbol->setSize(m_symbolSize, m_symbolSize);
symbol->setColor(curveColor);
@@ -683,6 +700,14 @@ RiuQwtSymbol::PointSymbolEnum RimPlotCurve::symbol()
return m_pointSymbol();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimPlotCurve::symbolSize() const
{
return m_symbolSize();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -715,6 +740,14 @@ void RimPlotCurve::setSymbolLabel(const QString& label)
m_symbolLabel = label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setSymbolLabelPosition(RiuQwtSymbol::LabelPosition labelPosition)
{
m_symbolLabelPosition = labelPosition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -41,6 +41,7 @@ public:
typedef caf::AppEnum<RiuQwtPlotCurve::CurveInterpolationEnum> CurveInterpolation;
typedef caf::AppEnum<RiuQwtPlotCurve::LineStyleEnum> LineStyle;
typedef caf::AppEnum<RiuQwtSymbol::PointSymbolEnum> PointSymbol;
typedef caf::AppEnum<RiuQwtSymbol::LabelPosition> LabelPosition;
public:
RimPlotCurve();
@@ -62,10 +63,12 @@ public:
void setLineStyle(RiuQwtPlotCurve::LineStyleEnum lineStyle);
void setSymbol(RiuQwtSymbol::PointSymbolEnum symbolStyle);
RiuQwtSymbol::PointSymbolEnum symbol();
int symbolSize() const;
cvf::Color3f symbolEdgeColor() const;
void setSymbolEdgeColor(const cvf::Color3f& edgeColor);
void setSymbolSkipDistance(float distance);
void setSymbolLabel(const QString& label);
void setSymbolLabelPosition(RiuQwtSymbol::LabelPosition labelPosition);
void setSymbolSize(int sizeInPixels);
void setLineThickness(int thickness);
void resetAppearance();
@@ -128,7 +131,7 @@ protected:
caf::PdmField<QString> m_curveName;
caf::PdmField<QString> m_customCurveName;
caf::PdmField<bool> m_showLegend;
QString m_symbolLabel;
caf::PdmField<QString> m_symbolLabel;
caf::PdmField<int> m_symbolSize;
caf::PdmField<QString> m_legendEntryText;
@@ -141,7 +144,7 @@ protected:
caf::PdmField<PointSymbol> m_pointSymbol;
caf::PdmField<LineStyle> m_lineStyle;
caf::PdmField<CurveInterpolation> m_curveInterpolation;
RiuQwtSymbol::LabelPosition m_symbolLabelPosition;
caf::PdmField<LabelPosition> m_symbolLabelPosition;
caf::PdmField<cvf::Color3f> m_symbolEdgeColor;
};
@@ -23,7 +23,7 @@
#include "RiaSummaryCurveDefinition.h"
#include "RiaSummaryTools.h"
#include "RiaTimeHistoryCurveMerger.h"
#include "RiaCurveMerger.h"
#include "RimProject.h"
#include "RimSummaryAddress.h"
@@ -267,7 +267,7 @@ bool RimSummaryCalculation::calculate()
std::vector<time_t> curveTimeSteps = RiaSummaryCurveDefinition::timeSteps(curveDef);
timeHistoryCurveMerger.addCurveData(curveValues, curveTimeSteps);
timeHistoryCurveMerger.addCurveData(curveTimeSteps, curveValues);
}
timeHistoryCurveMerger.computeInterpolatedValues();
@@ -277,11 +277,11 @@ bool RimSummaryCalculation::calculate()
{
RimSummaryCalculationVariable* v = m_variables[i];
parser.assignVector(v->name(), timeHistoryCurveMerger.interpolatedCurveValuesForAllTimeSteps(i));
parser.assignVector(v->name(), timeHistoryCurveMerger.interpolatedYValuesForAllXValues(i));
}
std::vector<double> resultValues;
resultValues.resize(timeHistoryCurveMerger.allTimeSteps().size());
resultValues.resize(timeHistoryCurveMerger.allXValues().size());
parser.assignVector(leftHandSideVariableName, resultValues);
@@ -293,16 +293,16 @@ bool RimSummaryCalculation::calculate()
m_timesteps.v().clear();
m_calculatedValues.v().clear();
if (timeHistoryCurveMerger.validIntervalsForAllTimeSteps().size() > 0)
if (timeHistoryCurveMerger.validIntervalsForAllXValues().size() > 0)
{
size_t firstValidTimeStep = timeHistoryCurveMerger.validIntervalsForAllTimeSteps().front().first;
size_t lastValidTimeStep = timeHistoryCurveMerger.validIntervalsForAllTimeSteps().back().second + 1;
size_t firstValidTimeStep = timeHistoryCurveMerger.validIntervalsForAllXValues().front().first;
size_t lastValidTimeStep = timeHistoryCurveMerger.validIntervalsForAllXValues().back().second + 1;
if (lastValidTimeStep > firstValidTimeStep &&
lastValidTimeStep <= timeHistoryCurveMerger.allTimeSteps().size())
lastValidTimeStep <= timeHistoryCurveMerger.allXValues().size())
{
std::vector<time_t> validTimeSteps(timeHistoryCurveMerger.allTimeSteps().begin() + firstValidTimeStep,
timeHistoryCurveMerger.allTimeSteps().begin() + lastValidTimeStep);
std::vector<time_t> validTimeSteps(timeHistoryCurveMerger.allXValues().begin() + firstValidTimeStep,
timeHistoryCurveMerger.allXValues().begin() + lastValidTimeStep);
std::vector<double> validValues(resultValues.begin() + firstValidTimeStep,
@@ -1,22 +1,21 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimWellLogRftCurve.h"
#include "RiaApplication.h"
@@ -37,6 +36,8 @@
#include "RimEclipseResultCase.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimTools.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotCollection.h"
@@ -60,26 +61,31 @@
namespace caf
{
template<>
void caf::AppEnum< RifEclipseRftAddress::RftWellLogChannelType >::setUp()
{
addItem(RifEclipseRftAddress::NONE, "NONE", "None");
addItem(RifEclipseRftAddress::DEPTH, "DEPTH", "Depth");
addItem(RifEclipseRftAddress::PRESSURE, "PRESSURE", "Pressure");
addItem(RifEclipseRftAddress::SWAT, "SWAT", "Water Saturation");
addItem(RifEclipseRftAddress::SOIL, "SOIL", "Oil Saturation");
addItem(RifEclipseRftAddress::SGAS, "SGAS", "Gas Saturation");
addItem(RifEclipseRftAddress::WRAT, "WRAT", "Water Flow");
addItem(RifEclipseRftAddress::ORAT, "ORAT", "Oil Flow");
addItem(RifEclipseRftAddress::GRAT, "GRAT", "Gas flow");
setDefault(RifEclipseRftAddress::NONE);
}
template<>
void caf::AppEnum<RifEclipseRftAddress::RftWellLogChannelType>::setUp()
{
addItem(RifEclipseRftAddress::NONE, "NONE", "None");
addItem(RifEclipseRftAddress::TVD, "DEPTH", "Depth");
addItem(RifEclipseRftAddress::PRESSURE, "PRESSURE", "Pressure");
addItem(RifEclipseRftAddress::SWAT, "SWAT", "Water Saturation");
addItem(RifEclipseRftAddress::SOIL, "SOIL", "Oil Saturation");
addItem(RifEclipseRftAddress::SGAS, "SGAS", "Gas Saturation");
addItem(RifEclipseRftAddress::WRAT, "WRAT", "Water Flow");
addItem(RifEclipseRftAddress::ORAT, "ORAT", "Oil Flow");
addItem(RifEclipseRftAddress::GRAT, "GRAT", "Gas flow");
addItem(RifEclipseRftAddress::MD, "MD", "Measured Depth");
addItem(RifEclipseRftAddress::PRESSURE_P10, "PRESSURE_P10", "Pressure P10");
addItem(RifEclipseRftAddress::PRESSURE_P50, "PRESSURE_P50", "Pressure P50");
addItem(RifEclipseRftAddress::PRESSURE_P90, "PRESSURE_P90", "Pressure P90");
addItem(RifEclipseRftAddress::PRESSURE_MEAN, "PRESSURE_MEAN", "Pressure Mean");
setDefault(RifEclipseRftAddress::NONE);
}
} // namespace caf
CAF_PDM_SOURCE_INIT(RimWellLogRftCurve, "WellLogRftCurve");
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RimWellLogRftCurve::RimWellLogRftCurve()
{
@@ -88,12 +94,23 @@ RimWellLogRftCurve::RimWellLogRftCurve()
CAF_PDM_InitFieldNoDefault(&m_eclipseResultCase, "CurveEclipseResultCase", "Eclipse Result Case", "", "", "");
m_eclipseResultCase.uiCapability()->setUiTreeChildrenHidden(true);
CAF_PDM_InitFieldNoDefault(&m_summaryCase, "CurveSummaryCase", "Summary Case", "", "", "");
m_summaryCase.uiCapability()->setUiTreeChildrenHidden(true);
CAF_PDM_InitFieldNoDefault(&m_ensemble, "CurveEnsemble", "Ensemble", "", "", "");
m_ensemble.uiCapability()->setUiTreeChildrenHidden(true);
CAF_PDM_InitFieldNoDefault(&m_timeStep, "TimeStep", "Time Step", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellName, "WellName", "Well Name", "", "", "");
CAF_PDM_InitField(&m_branchIndex, "BranchIndex", 0, "Branch Index", "", "", "");
CAF_PDM_InitField(&m_branchDetection, "BranchDetection", true, "Branch Detection", "",
"Compute branches based on how simulation well cells are organized", "");
CAF_PDM_InitField(&m_branchDetection,
"BranchDetection",
true,
"Branch Detection",
"",
"Compute branches based on how simulation well cells are organized",
"");
CAF_PDM_InitFieldNoDefault(&m_wellLogChannelName, "WellLogChannelName", "Well Property", "", "", "");
@@ -101,14 +118,12 @@ RimWellLogRftCurve::RimWellLogRftCurve()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RimWellLogRftCurve::~RimWellLogRftCurve()
{
}
RimWellLogRftCurve::~RimWellLogRftCurve() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QString RimWellLogRftCurve::wellName() const
{
@@ -116,7 +131,7 @@ QString RimWellLogRftCurve::wellName() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QString RimWellLogRftCurve::wellLogChannelName() const
{
@@ -124,7 +139,7 @@ QString RimWellLogRftCurve::wellLogChannelName() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RimWellLogRftCurve::setEclipseResultCase(RimEclipseResultCase* eclipseResultCase)
{
@@ -132,7 +147,7 @@ void RimWellLogRftCurve::setEclipseResultCase(RimEclipseResultCase* eclipseResul
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RimEclipseResultCase* RimWellLogRftCurve::eclipseResultCase() const
{
@@ -140,12 +155,44 @@ RimEclipseResultCase* RimWellLogRftCurve::eclipseResultCase() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RimWellLogRftCurve::setSummaryCase(RimSummaryCase* summaryCase)
{
m_summaryCase = summaryCase;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCase* RimWellLogRftCurve::summaryCase() const
{
return m_summaryCase;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogRftCurve::setEnsemble(RimSummaryCaseCollection* ensemble)
{
m_ensemble = ensemble;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCaseCollection* RimWellLogRftCurve::ensemble() const
{
return m_ensemble;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogRftCurve::setRftAddress(RifEclipseRftAddress address)
{
m_timeStep = address.timeStep();
m_wellName = address.wellName();
m_timeStep = address.timeStep();
m_wellName = address.wellName();
m_wellLogChannelName = address.wellLogChannel();
}
@@ -158,21 +205,21 @@ RifEclipseRftAddress RimWellLogRftCurve::rftAddress() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RimWellLogRftCurve::setDefaultAddress(QString wellName)
{
RifReaderEclipseRft* reader = rftReader();
RifReaderRftInterface* reader = rftReader();
if (!reader) return;
bool wellNameHasRftData = false;
std::set<QString> wellNames = reader->wellNames();
bool wellNameHasRftData = false;
std::set<QString> wellNames = reader->wellNames();
for (const QString& wellNameWithRft : wellNames)
{
if (wellName == wellNameWithRft)
{
wellNameHasRftData = true;
m_wellName = wellName;
m_wellName = wellName;
break;
}
}
@@ -180,16 +227,16 @@ void RimWellLogRftCurve::setDefaultAddress(QString wellName)
if (!wellNameHasRftData)
{
m_wellLogChannelName = RifEclipseRftAddress::NONE;
m_timeStep = QDateTime();
m_timeStep = QDateTime();
return;
}
m_wellLogChannelName = RifEclipseRftAddress::PRESSURE;
std::vector<QDateTime> timeSteps = reader->availableTimeSteps(m_wellName, m_wellLogChannelName());
if (timeSteps.size() > 0)
std::set<QDateTime> timeSteps = reader->availableTimeSteps(m_wellName, m_wellLogChannelName());
if (!timeSteps.empty())
{
m_timeStep = timeSteps[0];
m_timeStep = *(timeSteps.begin());
}
else
{
@@ -198,7 +245,7 @@ void RimWellLogRftCurve::setDefaultAddress(QString wellName)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RimWellLogRftCurve::updateWellChannelNameAndTimeStep()
{
@@ -208,43 +255,43 @@ void RimWellLogRftCurve::updateWellChannelNameAndTimeStep()
return;
}
RifReaderEclipseRft* reader = rftReader();
RifReaderRftInterface* reader = rftReader();
if (!reader) return;
std::vector<RifEclipseRftAddress::RftWellLogChannelType> channelNames = reader->availableWellLogChannels(m_wellName);
std::set<RifEclipseRftAddress::RftWellLogChannelType> channelNames = reader->availableWellLogChannels(m_wellName);
if (channelNames.empty())
{
m_wellLogChannelName = RifEclipseRftAddress::NONE;
}
else if (std::find(channelNames.begin(), channelNames.end(), m_wellLogChannelName()) == channelNames.end())
else if (!channelNames.count(m_wellLogChannelName()))
{
m_wellLogChannelName = RifEclipseRftAddress::PRESSURE;
}
std::vector<QDateTime> timeSteps = reader->availableTimeSteps(m_wellName, m_wellLogChannelName());
std::set<QDateTime> timeSteps = reader->availableTimeSteps(m_wellName, m_wellLogChannelName());
if (timeSteps.empty())
{
m_timeStep = QDateTime();
}
else if (std::find(timeSteps.begin(), timeSteps.end(), m_timeStep()) == timeSteps.end())
else if (!timeSteps.count(m_timeStep()))
{
m_timeStep = timeSteps[0];
m_timeStep = *(timeSteps.begin());
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RimWellLogRftCurve::setSimWellBranchData(bool branchDetection, int branchIndex)
{
m_branchDetection = branchDetection;
m_branchIndex = branchIndex;
m_branchIndex = branchIndex;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QString RimWellLogRftCurve::createCurveAutoName()
{
@@ -261,12 +308,21 @@ QString RimWellLogRftCurve::createCurveAutoName()
{
name.push_back(m_eclipseResultCase->caseUserDescription());
}
else if (m_summaryCase)
{
name.push_back(m_summaryCase->caseName());
}
else if (m_ensemble)
{
name.push_back(m_ensemble->name());
}
if (wellLogChannelName() != caf::AppEnum<RifEclipseRftAddress::RftWellLogChannelType>::text(RifEclipseRftAddress::NONE))
{
RifEclipseRftAddress::RftWellLogChannelType channelNameEnum = caf::AppEnum<RifEclipseRftAddress::RftWellLogChannelType>::fromText(wellLogChannelName());
{
RifEclipseRftAddress::RftWellLogChannelType channelNameEnum =
caf::AppEnum<RifEclipseRftAddress::RftWellLogChannelType>::fromText(wellLogChannelName());
name.push_back(caf::AppEnum<RifEclipseRftAddress::RftWellLogChannelType>::uiText(channelNameEnum));
}
if ( !m_timeStep().isNull())
if (!m_timeStep().isNull())
{
name.push_back(m_timeStep().toString(RiaQDateTimeTools::dateFormatString()));
}
@@ -275,14 +331,14 @@ QString RimWellLogRftCurve::createCurveAutoName()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RimWellLogRftCurve::onLoadDataAndUpdate(bool updateParentPlot)
{
this->RimPlotCurve::updateCurvePresentation(updateParentPlot);
m_isUsingPseudoLength = false;
if (isCurveVisible())
{
m_curveData = new RigWellLogCurveData;
@@ -292,18 +348,41 @@ void RimWellLogRftCurve::onLoadDataAndUpdate(bool updateParentPlot)
CVF_ASSERT(wellLogPlot);
std::vector<double> measuredDepthVector = measuredDepthValues();
std::vector<double> tvDepthVector = tvDepthValues();
std::vector<double> values = xValues();
std::vector<double> tvDepthVector = tvDepthValues();
std::vector<double> values = xValues();
if (values.empty() ||
values.size() != tvDepthVector.size() ||
values.size() != measuredDepthVector.size())
if (values.empty() || values.size() != tvDepthVector.size())
{
this->detachQwtCurve();
return;
}
m_curveData->setValuesWithTVD(values, measuredDepthVector, tvDepthVector, RiaEclipseUnitTools::depthUnit(m_eclipseResultCase->eclipseCaseData()->unitsType()), false);
RiaEclipseUnitTools::UnitSystem unitSystem = RiaEclipseUnitTools::UNITS_METRIC;
if (m_eclipseResultCase)
{
unitSystem = m_eclipseResultCase->eclipseCaseData()->unitsType();
}
else if (m_summaryCase)
{
unitSystem = m_summaryCase->unitsSystem();
}
else if (m_ensemble)
{
unitSystem = m_ensemble->unitSystem();
}
else
{
CVF_ASSERT(false && "Need to have either an eclipse result case, a summary case or an ensemble");
}
if (tvDepthVector.size() != measuredDepthVector.size())
{
m_isUsingPseudoLength = true;
measuredDepthVector = tvDepthVector;
}
m_curveData->setValuesWithTVD(
values, measuredDepthVector, tvDepthVector, RiaEclipseUnitTools::depthUnit(unitSystem), false);
RiaDefines::DepthUnitType displayUnit = RiaDefines::UNIT_METER;
if (wellLogPlot)
@@ -313,11 +392,15 @@ void RimWellLogRftCurve::onLoadDataAndUpdate(bool updateParentPlot)
if (wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH)
{
m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(), m_curveData->measuredDepthPlotValues(displayUnit).data(), static_cast<int>(m_curveData->xPlotValues().size()));
m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(),
m_curveData->measuredDepthPlotValues(displayUnit).data(),
static_cast<int>(m_curveData->xPlotValues().size()));
}
else
{
m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(), m_curveData->trueDepthPlotValues(displayUnit).data(), static_cast<int>(m_curveData->xPlotValues().size()));
m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(),
m_curveData->trueDepthPlotValues(displayUnit).data(),
static_cast<int>(m_curveData->xPlotValues().size()));
m_isUsingPseudoLength = false;
}
@@ -349,7 +432,7 @@ void RimWellLogRftCurve::onLoadDataAndUpdate(bool updateParentPlot)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RimWellLogRftCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
@@ -359,10 +442,8 @@ void RimWellLogRftCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderi
curveDataGroup->add(&m_eclipseResultCase);
curveDataGroup->add(&m_wellName);
RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromWellName(curveDataGroup,
m_wellName,
m_branchDetection,
m_branchIndex);
RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromWellName(
curveDataGroup, m_wellName, m_branchDetection, m_branchIndex);
curveDataGroup->add(&m_wellLogChannelName);
curveDataGroup->add(&m_timeStep);
@@ -378,9 +459,10 @@ void RimWellLogRftCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderi
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimWellLogRftCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
QList<caf::PdmOptionItemInfo> RimWellLogRftCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
@@ -397,7 +479,7 @@ QList<caf::PdmOptionItemInfo> RimWellLogRftCurve::calculateValueOptions(const ca
else if (fieldNeedingOptions == &m_wellName)
{
options.push_back(caf::PdmOptionItemInfo("None", ""));
RifReaderEclipseRft* reader = rftReader();
RifReaderRftInterface* reader = rftReader();
if (reader)
{
std::set<QString> wellNames = reader->wellNames();
@@ -409,26 +491,29 @@ QList<caf::PdmOptionItemInfo> RimWellLogRftCurve::calculateValueOptions(const ca
}
else if (fieldNeedingOptions == &m_wellLogChannelName)
{
RifReaderEclipseRft* reader = rftReader();
RifReaderRftInterface* reader = rftReader();
if (reader)
{
for (const RifEclipseRftAddress::RftWellLogChannelType& channelName : reader->availableWellLogChannels(m_wellName))
{
options.push_back(caf::PdmOptionItemInfo(caf::AppEnum<RifEclipseRftAddress::RftWellLogChannelType>::uiText(channelName), channelName));
options.push_back(caf::PdmOptionItemInfo(
caf::AppEnum<RifEclipseRftAddress::RftWellLogChannelType>::uiText(channelName), channelName));
}
}
if (options.empty())
{
options.push_back(caf::PdmOptionItemInfo(caf::AppEnum<RifEclipseRftAddress::RftWellLogChannelType>::uiText(RifEclipseRftAddress::NONE), RifEclipseRftAddress::NONE));
options.push_back(caf::PdmOptionItemInfo(
caf::AppEnum<RifEclipseRftAddress::RftWellLogChannelType>::uiText(RifEclipseRftAddress::NONE),
RifEclipseRftAddress::NONE));
}
}
else if (fieldNeedingOptions == &m_timeStep)
{
RifReaderEclipseRft* reader = rftReader();
RifReaderRftInterface* reader = rftReader();
if (reader)
{
QString dateFormat = "dd MMM yyyy";
std::vector<QDateTime> timeStamps = reader->availableTimeSteps(m_wellName, m_wellLogChannelName());
QString dateFormat = "dd MMM yyyy";
std::set<QDateTime> timeStamps = reader->availableTimeSteps(m_wellName, m_wellLogChannelName());
for (const QDateTime& dt : timeStamps)
{
QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale(dt, dateFormat);
@@ -441,7 +526,7 @@ QList<caf::PdmOptionItemInfo> RimWellLogRftCurve::calculateValueOptions(const ca
}
else if (fieldNeedingOptions == &m_branchIndex)
{
auto simulationWellBranches =
auto simulationWellBranches =
RiaSimWellBranchTools::simulationWellBranches(RimWellPlotTools::simWellName(m_wellName), m_branchDetection);
options = RiaSimWellBranchTools::valueOptionsForBranchIndexField(simulationWellBranches);
@@ -451,17 +536,19 @@ QList<caf::PdmOptionItemInfo> RimWellLogRftCurve::calculateValueOptions(const ca
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RimWellLogRftCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
void RimWellLogRftCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue)
{
m_idxInWellPathToIdxInRftFile.clear();
RimWellLogCurve::fieldChangedByUi(changedField, oldValue, newValue);
if (changedField == &m_eclipseResultCase)
{
m_timeStep = QDateTime();
m_wellName = "";
m_timeStep = QDateTime();
m_wellName = "";
m_wellLogChannelName = RifEclipseRftAddress::NONE;
this->loadDataAndUpdate(true);
@@ -473,8 +560,7 @@ void RimWellLogRftCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFiel
updateWellChannelNameAndTimeStep();
this->loadDataAndUpdate(true);
}
else if (changedField == &m_branchDetection ||
changedField == &m_branchIndex)
else if (changedField == &m_branchDetection || changedField == &m_branchIndex)
{
QString simWellName = RimWellPlotTools::simWellName(m_wellName);
@@ -498,24 +584,32 @@ void RimWellLogRftCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFiel
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RifReaderEclipseRft* RimWellLogRftCurve::rftReader() const
RifReaderRftInterface* RimWellLogRftCurve::rftReader() const
{
if (!m_eclipseResultCase()) return nullptr;
return m_eclipseResultCase()->rftReader();
if (m_eclipseResultCase())
{
return m_eclipseResultCase()->rftReader();
}
else if (m_summaryCase())
{
return m_summaryCase()->rftReader();
}
else if (m_ensemble())
{
return m_ensemble()->rftStatisticsReader();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigEclipseWellLogExtractor* RimWellLogRftCurve::extractor()
{
if (!m_eclipseResultCase()) return nullptr;
RifReaderEclipseRft* reader = rftReader();
RifReaderRftInterface* reader = rftReader();
if (!reader) return nullptr;
RimMainPlotCollection* mainPlotCollection;
this->firstAncestorOrThisOfTypeAsserted(mainPlotCollection);
@@ -525,13 +619,13 @@ RigEclipseWellLogExtractor* RimWellLogRftCurve::extractor()
RigEclipseWellLogExtractor* eclExtractor = nullptr;
RimProject* proj = RiaApplication::instance()->project();
RimProject* proj = RiaApplication::instance()->project();
RimWellPath* wellPath = proj->wellPathFromSimWellName(m_wellName());
eclExtractor = wellLogCollection->findOrCreateExtractor(wellPath, m_eclipseResultCase);
eclExtractor = wellLogCollection->findOrCreateExtractor(wellPath, m_eclipseResultCase);
if (!eclExtractor)
{
QString simWellName = RimWellPlotTools::simWellName(m_wellName);
QString simWellName = RimWellPlotTools::simWellName(m_wellName);
std::vector<const RigWellPath*> wellPaths = RiaSimWellBranchTools::simulationWellBranches(simWellName, m_branchDetection);
if (wellPaths.size() == 0) return nullptr;
@@ -539,10 +633,8 @@ RigEclipseWellLogExtractor* RimWellLogRftCurve::extractor()
auto wellPathBranch = wellPaths[m_branchIndex];
eclExtractor = wellLogCollection->findOrCreateSimWellExtractor(simWellName,
QString("Find or create sim well extractor"),
wellPathBranch,
m_eclipseResultCase->eclipseCaseData());
eclExtractor = wellLogCollection->findOrCreateSimWellExtractor(
simWellName, QString("Find or create sim well extractor"), wellPathBranch, m_eclipseResultCase->eclipseCaseData());
m_isUsingPseudoLength = true;
}
@@ -550,7 +642,7 @@ RigEclipseWellLogExtractor* RimWellLogRftCurve::extractor()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RimWellLogRftCurve::createWellPathIdxToRftFileIdxMapping()
{
@@ -573,16 +665,19 @@ bool RimWellLogRftCurve::createWellPathIdxToRftFileIdxMapping()
globCellIndicesToIndexInWell[intersections[idx].globCellIndex] = idx;
}
RifEclipseRftAddress depthAddress(m_wellName(), m_timeStep, RifEclipseRftAddress::DEPTH);
RifEclipseRftAddress depthAddress(m_wellName(), m_timeStep, RifEclipseRftAddress::TVD);
std::vector<caf::VecIjk> rftIndices;
rftReader()->cellIndices(depthAddress, &rftIndices);
RifReaderEclipseRft* eclipseRftReader = dynamic_cast<RifReaderEclipseRft*>(rftReader());
if (!eclipseRftReader) return false;
eclipseRftReader->cellIndices(depthAddress, &rftIndices);
const RigMainGrid* mainGrid = eclExtractor->caseData()->mainGrid();
for (size_t idx = 0; idx < rftIndices.size(); idx++)
{
caf::VecIjk ijkIndex = rftIndices[idx];
size_t globalCellIndex = mainGrid->cellIndexFromIJK(ijkIndex.i(), ijkIndex.j(), ijkIndex.k());
caf::VecIjk ijkIndex = rftIndices[idx];
size_t globalCellIndex = mainGrid->cellIndexFromIJK(ijkIndex.i(), ijkIndex.j(), ijkIndex.k());
if (globCellIndicesToIndexInWell.find(globalCellIndex) != globCellIndicesToIndexInWell.end())
{
@@ -594,7 +689,7 @@ bool RimWellLogRftCurve::createWellPathIdxToRftFileIdxMapping()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
size_t RimWellLogRftCurve::rftFileIndex(size_t wellPathIndex)
{
@@ -612,7 +707,7 @@ size_t RimWellLogRftCurve::rftFileIndex(size_t wellPathIndex)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<size_t> RimWellLogRftCurve::sortedIndicesInRftFile()
{
@@ -631,19 +726,19 @@ std::vector<size_t> RimWellLogRftCurve::sortedIndicesInRftFile()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimWellLogRftCurve::xValues()
{
RifReaderEclipseRft* reader = rftReader();
std::vector<double> values;
RifReaderRftInterface* reader = rftReader();
std::vector<double> values;
if (!reader) return values;
RifEclipseRftAddress address(m_wellName(), m_timeStep, m_wellLogChannelName());
reader->values(address, &values);
bool wellPathExists = createWellPathIdxToRftFileIdxMapping();
if (wellPathExists)
@@ -657,7 +752,7 @@ std::vector<double> RimWellLogRftCurve::xValues()
valuesSorted.push_back((values.at(idx)));
}
}
return valuesSorted;
}
else
@@ -667,16 +762,16 @@ std::vector<double> RimWellLogRftCurve::xValues()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimWellLogRftCurve::tvDepthValues()
{
RifReaderEclipseRft* reader = rftReader();
std::vector<double> values;
RifReaderRftInterface* reader = rftReader();
std::vector<double> values;
if (!reader) return values;
RifEclipseRftAddress depthAddress(m_wellName(), m_timeStep, RifEclipseRftAddress::DEPTH);
RifEclipseRftAddress depthAddress(m_wellName(), m_timeStep, RifEclipseRftAddress::TVD);
reader->values(depthAddress, &values);
bool wellPathExists = createWellPathIdxToRftFileIdxMapping();
@@ -702,38 +797,37 @@ std::vector<double> RimWellLogRftCurve::tvDepthValues()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimWellLogRftCurve::measuredDepthValues()
{
std::vector<double> measuredDepthForCells;
RigEclipseWellLogExtractor* eclExtractor = extractor();
if (!eclExtractor) return measuredDepthForCells;
std::vector<double> measuredDepthForIntersections = eclExtractor->cellIntersectionMDs();
if (measuredDepthForIntersections.empty())
{
return measuredDepthForCells;
}
std::vector< size_t> globCellIndices = eclExtractor->intersectedCellsGlobIdx();
std::vector<size_t> globCellIndices = eclExtractor->intersectedCellsGlobIdx();
for (size_t i = 0; i < globCellIndices.size() - 1; i = i + 2)
{
double sum = measuredDepthForIntersections[i] + measuredDepthForIntersections[i + 1];
measuredDepthForCells.push_back( sum / 2.0 );
measuredDepthForCells.push_back(sum / 2.0);
}
std::vector<double> measuredDepthForCellsWhichHasRftData;
for (size_t i = 0; i < measuredDepthForCells.size(); i++)
{
if(rftFileIndex(i) != cvf::UNDEFINED_SIZE_T)
if (rftFileIndex(i) != cvf::UNDEFINED_SIZE_T)
{
measuredDepthForCellsWhichHasRftData.push_back(measuredDepthForCells[i]);
}
@@ -31,9 +31,11 @@
#include <map>
class RifReaderEclipseRft;
class RifReaderRftInterface;
class RigEclipseWellLogExtractor;
class RimEclipseResultCase;
class RimSummaryCase;
class RimSummaryCaseCollection;
class RimWellPath;
//==================================================================================================
@@ -54,6 +56,12 @@ public:
void setEclipseResultCase(RimEclipseResultCase* eclipseResultCase);
RimEclipseResultCase* eclipseResultCase() const;
void setSummaryCase(RimSummaryCase* summaryCase);
RimSummaryCase* summaryCase() const;
void setEnsemble(RimSummaryCaseCollection* ensemble);
RimSummaryCaseCollection* ensemble() const;
void setRftAddress(RifEclipseRftAddress address);
RifEclipseRftAddress rftAddress() const;
@@ -73,7 +81,7 @@ protected:
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
private:
RifReaderEclipseRft* rftReader() const;
RifReaderRftInterface* rftReader() const;
RigEclipseWellLogExtractor* extractor();
@@ -86,11 +94,13 @@ private:
std::vector<double> measuredDepthValues();
private:
caf::PdmPtrField<RimEclipseResultCase*> m_eclipseResultCase;
caf::PdmField<QDateTime> m_timeStep;
caf::PdmField<QString> m_wellName;
caf::PdmField<int> m_branchIndex;
caf::PdmField<bool> m_branchDetection;
caf::PdmPtrField<RimEclipseResultCase*> m_eclipseResultCase;
caf::PdmPtrField<RimSummaryCase*> m_summaryCase;
caf::PdmPtrField<RimSummaryCaseCollection*> m_ensemble;
caf::PdmField<QDateTime> m_timeStep;
caf::PdmField<QString> m_wellName;
caf::PdmField<int> m_branchIndex;
caf::PdmField<bool> m_branchDetection;
std::map<size_t, size_t> m_idxInWellPathToIdxInRftFile;
bool m_isUsingPseudoLength;
@@ -110,3 +110,11 @@ RimSummaryCalculation* RifCalculatedSummaryCurveReader::findCalculationByName(co
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaEclipseUnitTools::UnitSystem RifCalculatedSummaryCurveReader::unitSystem() const
{
return RiaEclipseUnitTools::UNITS_UNKNOWN;
}
@@ -44,6 +44,9 @@ public:
RimSummaryCalculation* findCalculationByName(const RifEclipseSummaryAddress& resultAddress) const;
RiaEclipseUnitTools::UnitSystem unitSystem() const override;
private:
caf::PdmPointer<RimSummaryCalculationCollection> m_calculationCollection;
};
@@ -20,7 +20,7 @@
#include "RiaLogging.h"
#include "RiaSummaryTools.h"
#include "RiaTimeHistoryCurveMerger.h"
#include "RiaCurveMerger.h"
#include "RifDerivedEnsembleReader.h"
@@ -151,14 +151,14 @@ void RimDerivedEnsembleCase::calculate(const RifEclipseSummaryAddress& address)
reader1->values(address, &values1);
reader2->values(address, &values2);
merger.addCurveData(values1, reader1->timeSteps(address));
merger.addCurveData(values2, reader2->timeSteps(address));
merger.addCurveData(reader1->timeSteps(address), values1);
merger.addCurveData(reader2->timeSteps(address), values2);
merger.computeInterpolatedValues();
std::vector<double>& allValues1 = merger.interpolatedCurveValuesForAllTimeSteps(0);
std::vector<double>& allValues2 = merger.interpolatedCurveValuesForAllTimeSteps(1);
std::vector<double>& allValues1 = merger.interpolatedYValuesForAllXValues(0);
std::vector<double>& allValues2 = merger.interpolatedYValuesForAllXValues(1);
size_t sampleCount = merger.allTimeSteps().size();
size_t sampleCount = merger.allXValues().size();
std::vector<double> calculatedValues;
calculatedValues.reserve(sampleCount);
for (size_t i = 0; i < sampleCount; i++)
@@ -174,7 +174,7 @@ void RimDerivedEnsembleCase::calculate(const RifEclipseSummaryAddress& address)
}
auto& dataItem = m_data[address];
dataItem.first = merger.allTimeSteps();
dataItem.first = merger.allXValues();
dataItem.second = calculatedValues;
}
@@ -17,7 +17,6 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiaApplication.h"
#include "RiaTimeHistoryCurveMerger.h"
#include "SummaryPlotCommands/RicNewDerivedEnsembleFeature.h"
@@ -28,7 +28,6 @@
#include "RifReaderEclipseSummary.h"
#include "RigStatisticsMath.h"
#include "RiaTimeHistoryCurveMerger.h"
#include "RimDerivedEnsembleCaseCollection.h"
#include "RimEnsembleCurveFilter.h"
@@ -21,7 +21,6 @@
#include "RifSummaryReaderInterface.h"
#include "RigStatisticsMath.h"
#include "RiaTimeHistoryCurveMerger.h"
#include "RimEnsembleCurveSet.h"
#include "RimSummaryCase.h"
@@ -21,7 +21,6 @@
#include "RifEnsembleStatisticsReader.h"
#include "RigStatisticsMath.h"
#include "RiaTimeHistoryCurveMerger.h"
#include "RiaTimeHistoryCurveResampler.h"
#include "RimEnsembleCurveSet.h"
@@ -173,14 +172,25 @@ void RimEnsembleStatisticsCase::calculate(const std::vector<RimSummaryCase*> sum
}
double p10, p50, p90, mean;
calculateStatistics(valuesAtTimeStep, &p10, &p50, &p90, &mean);
RigStatisticsMath::calculateStatisticsCurves(valuesAtTimeStep, &p10, &p50, &p90, &mean);
if (p10 != DOUBLE_INF) m_p10Data.push_back(p10);
if (p50 != DOUBLE_INF) m_p50Data.push_back(p50);
if (p90 != DOUBLE_INF) m_p90Data.push_back(p90);
if (p10 != HUGE_VAL) m_p10Data.push_back(p10);
if (p50 != HUGE_VAL) m_p50Data.push_back(p50);
if (p90 != HUGE_VAL) m_p90Data.push_back(p90);
m_meanData.push_back(mean);
}
m_addressUsedInLastCalculation = inputAddress;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaEclipseUnitTools::UnitSystem RimEnsembleStatisticsCase::unitSystem() const
{
if (m_curveSet)
{
return m_curveSet->summaryCaseCollection()->unitSystem();
}
return RiaEclipseUnitTools::UNITS_UNKNOWN;
}
//--------------------------------------------------------------------------------------------------
@@ -193,7 +203,6 @@ void RimEnsembleStatisticsCase::clearData()
m_p50Data.clear();
m_p90Data.clear();
m_meanData.clear();
m_addressUsedInLastCalculation = RifEclipseSummaryAddress();
}
//--------------------------------------------------------------------------------------------------
@@ -239,57 +248,3 @@ std::vector<RimSummaryCase*> RimEnsembleStatisticsCase::validSummaryCases(const
return validCases;
}
//--------------------------------------------------------------------------------------------------
/// Algorithm:
/// https://en.wikipedia.org/wiki/Percentile#Third_variant,_'%22%60UNIQ--postMath-00000052-QINU%60%22'
//--------------------------------------------------------------------------------------------------
void RimEnsembleStatisticsCase::calculateStatistics(const std::vector<double>& values, double* p10, double* p50, double* p90, double* mean)
{
CVF_ASSERT(p10 && p50 && p90 && mean);
enum PValue { P10, P50, P90 };
std::vector<double> sortedValues;
double valueSum = 0;
{
std::multiset<double> vSet(values.begin(), values.end());
for (double v : vSet)
{
if (RiaStatisticsTools::isValidNumber(v))
{
sortedValues.push_back(v);
valueSum += v;
}
}
}
int valueCount = (int)sortedValues.size();
double percentiles[] = { 0.1, 0.5, 0.9 };
double pValues[] = { DOUBLE_INF, DOUBLE_INF, DOUBLE_INF };
for (int i = P10; i <= P90; i++)
{
// Check valid params
if ((percentiles[i] < 1.0 / ((double)valueCount + 1)) || (percentiles[i] > (double)valueCount / ((double)valueCount + 1))) continue;
double rank = percentiles[i] * (valueCount + 1) - 1;
double rankInt;
double rankFrac = std::modf(rank, &rankInt);
if (rankInt < valueCount - 1)
{
pValues[i] = sortedValues[rankInt] + rankFrac * (sortedValues[rankInt + 1] - sortedValues[rankInt]);
}
else
{
pValues[i] = sortedValues[rankInt];
}
}
*p10 = pValues[P10];
*p50 = pValues[P50];
*p90 = pValues[P90];
*mean = valueSum / valueCount;
}
@@ -19,6 +19,7 @@
#pragma once
#include "RiaEclipseUnitTools.h"
#include "RifEclipseSummaryAddress.h"
#include "RimSummaryCase.h"
@@ -55,12 +56,12 @@ public:
const RimEnsembleCurveSet* curveSet() const;
void calculate(const std::vector<RimSummaryCase*>& sumCases);
RiaEclipseUnitTools::UnitSystem unitSystem() const;
private:
void calculate(const std::vector<RimSummaryCase*> sumCases, const RifEclipseSummaryAddress& inputAddress);
void clearData();
void clearData();
std::vector<RimSummaryCase*> validSummaryCases(const std::vector<RimSummaryCase*> allSumCases, const RifEclipseSummaryAddress& inputAddress);
void calculateStatistics(const std::vector<double>& values, double* p10, double* p50, double* p90, double* mean);
private:
std::unique_ptr<RifEnsembleStatisticsReader> m_statisticsReader;
@@ -72,5 +73,4 @@ private:
std::vector<double> m_p90Data;
std::vector<double> m_meanData;
RifEclipseSummaryAddress m_addressUsedInLastCalculation;
};
@@ -22,6 +22,7 @@
#include "RifEclipseSummaryTools.h"
#include "RifReaderEclipseSummary.h"
#include "RifReaderEclipseRft.h"
#include "RimTools.h"
@@ -42,6 +43,7 @@ CAF_PDM_SOURCE_INIT(RimFileSummaryCase,"FileSummaryCase");
RimFileSummaryCase::RimFileSummaryCase()
{
CAF_PDM_InitField(&m_includeRestartFiles, "IncludeRestartFiles", false, "Include Restart Files", "", "", "");
m_includeRestartFiles.uiCapability()->setUiHidden(true);
}
@@ -84,7 +86,12 @@ void RimFileSummaryCase::updateFilePathsFromProjectPath(const QString & newProje
//--------------------------------------------------------------------------------------------------
void RimFileSummaryCase::createSummaryReaderInterface()
{
m_summaryFileReader = RimFileSummaryCase::findRelatedFilesAndCreateReader(this->summaryHeaderFilename(), m_includeRestartFiles);
m_summaryFileReader = RimFileSummaryCase::findRelatedFilesAndCreateReader(this->summaryHeaderFilename(), m_includeRestartFiles);
m_summaryEclipseRftReader = RimFileSummaryCase::findRftDataAndCreateReader(this->summaryHeaderFilename());
if (m_summaryEclipseRftReader.notNull())
{
RiaLogging::info(QString("Found RFT Data for %1").arg(this->summaryHeaderFilename()));
}
}
//--------------------------------------------------------------------------------------------------
@@ -105,6 +112,26 @@ RifReaderEclipseSummary* RimFileSummaryCase::findRelatedFilesAndCreateReader(con
return summaryFileReader;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderEclipseRft* RimFileSummaryCase::findRftDataAndCreateReader(const QString& headerFileName)
{
QFileInfo fileInfo(headerFileName);
QString folder = fileInfo.absolutePath();
QString rftFileName = folder + "/" + fileInfo.completeBaseName() + ".RFT";
QFileInfo rftFileInfo(rftFileName);
if (rftFileInfo.exists())
{
std::unique_ptr<RifReaderEclipseRft> rftReader(new RifReaderEclipseRft(rftFileInfo.filePath()));
return rftReader.release();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -113,6 +140,14 @@ RifSummaryReaderInterface* RimFileSummaryCase::summaryReader()
return m_summaryFileReader.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderRftInterface* RimFileSummaryCase::rftReader()
{
return m_summaryEclipseRftReader.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -22,6 +22,8 @@
#include "cvfObject.h"
#include "cafPdmField.h"
class RifReaderRftInterface;
class RifReaderEclipseRft;
class RifReaderEclipseSummary;
//==================================================================================================
@@ -42,12 +44,15 @@ public:
void createSummaryReaderInterface() override;
RifSummaryReaderInterface* summaryReader() override;
RifReaderRftInterface* rftReader() override;
void setIncludeRestartFiles(bool includeRestartFiles);
static RifReaderEclipseSummary* findRelatedFilesAndCreateReader(const QString& headerFileName, bool includeRestartFiles);
static RifReaderEclipseSummary* findRelatedFilesAndCreateReader(const QString& headerFileName, bool includeRestartFiles);
static RifReaderEclipseRft* findRftDataAndCreateReader(const QString& headerFileName);
private:
cvf::ref<RifReaderEclipseSummary> m_summaryFileReader;
cvf::ref<RifReaderEclipseRft> m_summaryEclipseRftReader;
caf::PdmField<bool> m_includeRestartFiles;
};
@@ -19,6 +19,7 @@
#include "RimSummaryCase.h"
#include "RiaSummaryTools.h"
#include "RifSummaryReaderInterface.h"
#include "RimMainPlotCollection.h"
#include "RimOilField.h"
@@ -168,6 +169,14 @@ void RimSummaryCase::updateOptionSensitivity()
m_shortName.uiCapability()->setUiReadOnly(m_useAutoShortName);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderRftInterface* RimSummaryCase::rftReader()
{
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -187,6 +196,19 @@ QString RimSummaryCase::shortName() const
return m_shortName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaEclipseUnitTools::UnitSystemType RimSummaryCase::unitsSystem()
{
RifSummaryReaderInterface* reader = summaryReader();
if (reader)
{
return reader->unitSystem();
}
return RiaEclipseUnitTools::UNITS_UNKNOWN;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RiaEclipseUnitTools.h"
#include "RigCaseRealizationParameters.h"
#include "cafPdmField.h"
@@ -24,6 +25,7 @@
#include <memory>
class RifReaderRftInterface;
class RifSummaryReaderInterface;
class RimSummaryCaseCollection;
@@ -43,12 +45,15 @@ public:
virtual QString summaryHeaderFilename() const;
virtual QString caseName() const = 0;
QString shortName() const;
RiaEclipseUnitTools::UnitSystemType unitsSystem();
void updateAutoShortName();
void updateOptionSensitivity();
virtual void createSummaryReaderInterface() = 0;
virtual RifSummaryReaderInterface* summaryReader() = 0;
virtual RifReaderRftInterface* rftReader();
virtual QString errorMessagesFromReader() { return QString(); }
virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) = 0;
@@ -22,10 +22,12 @@
#include "RimDerivedEnsembleCaseCollection.h"
#include "RimEnsembleCurveSet.h"
#include "RifReaderEnsembleStatisticsRft.h"
#include "RimGridSummaryCase.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RifReaderEclipseRft.h"
#include "RifSummaryReaderInterface.h"
#include <QFileDialog>
@@ -146,6 +148,8 @@ RimSummaryCaseCollection::RimSummaryCaseCollection()
CAF_PDM_InitField(&m_isEnsemble, "IsEnsemble", false, "Is Ensemble", "", "", "");
m_isEnsemble.uiCapability()->setUiHidden(true);
m_statisticsEclipseRftReader = new RifReaderEnsembleStatisticsRft(this);
m_commonAddressCount = 0;
}
@@ -284,6 +288,50 @@ std::set<RifEclipseSummaryAddress> RimSummaryCaseCollection::ensembleSummaryAddr
return addresses;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<QString> RimSummaryCaseCollection::wellsWithRftData() const
{
std::set<QString> allWellNames;
for (RimSummaryCase* summaryCase : m_cases)
{
RifReaderRftInterface* reader = summaryCase->rftReader();
if (reader)
{
std::set<QString> wellNames = reader->wellNames();
allWellNames.insert(wellNames.begin(), wellNames.end());
}
}
return allWellNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<QDateTime> RimSummaryCaseCollection::rftTimeStepsForWell(const QString& wellName) const
{
std::set<QDateTime> allTimeSteps;
for (RimSummaryCase* summaryCase : m_cases)
{
RifReaderRftInterface* reader = summaryCase->rftReader();
if (reader)
{
std::set<QDateTime> timeStep = reader->availableTimeSteps(wellName);
allTimeSteps.insert(timeStep.begin(), timeStep.end());
}
}
return allTimeSteps;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderRftInterface* RimSummaryCaseCollection::rftStatisticsReader()
{
return m_statisticsEclipseRftReader.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -528,6 +576,18 @@ bool RimSummaryCaseCollection::operator<(const RimSummaryCaseCollection& rhs) co
return name() < rhs.name();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaEclipseUnitTools::UnitSystem RimSummaryCaseCollection::unitSystem() const
{
if (m_cases.empty())
{
return RiaEclipseUnitTools::UNITS_UNKNOWN;
}
return m_cases[0]->unitsSystem();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -18,7 +18,10 @@
#pragma once
#include "RiaEclipseUnitTools.h"
#include "RifEclipseSummaryAddress.h"
#include "RifEclipseRftAddress.h"
#include "RifReaderEnsembleStatisticsRft.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
@@ -30,6 +33,8 @@
#include <utility>
#include <vector>
class RifReaderRftInterface;
class RifReaderEnsembleStatisticsRft;
class RimSummaryCase;
//==================================================================================================
@@ -87,6 +92,10 @@ public:
bool isEnsemble() const;
void setAsEnsemble(bool isEnsemble);
virtual std::set<RifEclipseSummaryAddress> ensembleSummaryAddresses() const;
std::set<QString> wellsWithRftData() const;
std::set<QDateTime> rftTimeStepsForWell(const QString& wellName) const;
RifReaderRftInterface* rftStatisticsReader();
EnsembleParameter ensembleParameter(const QString& paramName) const;
void calculateEnsembleParametersIntersectionHash();
void clearEnsembleParametersHashes();
@@ -95,6 +104,8 @@ public:
static bool validateEnsembleCases(const std::vector<RimSummaryCase*> cases);
bool operator<(const RimSummaryCaseCollection& rhs) const;
RiaEclipseUnitTools::UnitSystem unitSystem() const;
private:
caf::PdmFieldHandle* userDescriptionField() override;
QString nameAndItemCount() const;
@@ -112,9 +123,10 @@ protected:
caf::PdmChildArrayField<RimSummaryCase*> m_cases;
private:
caf::PdmField<QString> m_name;
caf::PdmProxyValueField<QString> m_nameAndItemCount;
caf::PdmField<bool> m_isEnsemble;
caf::PdmField<QString> m_name;
caf::PdmProxyValueField<QString> m_nameAndItemCount;
caf::PdmField<bool> m_isEnsemble;
cvf::ref<RifReaderEnsembleStatisticsRft> m_statisticsEclipseRftReader;
size_t m_commonAddressCount; // if different address count among cases, set to 0
};
@@ -18,10 +18,10 @@
#include "RimSummaryCurve.h"
#include "RiaCurveMerger.h"
#include "RiaDefines.h"
#include "RiaGuiApplication.h"
#include "RiaPreferences.h"
#include "RiaTimeHistoryCurveMerger.h"
#include "RifReaderEclipseSummary.h"
@@ -490,14 +490,14 @@ void RimSummaryCurve::onLoadDataAndUpdate(bool updateParentPlot)
else
{
RiaTimeHistoryCurveMerger curveMerger;
curveMerger.addCurveData(curveValuesX, curveTimeStepsX);
curveMerger.addCurveData(curveValuesY, curveTimeStepsY);
curveMerger.addCurveData(curveTimeStepsX, curveValuesX);
curveMerger.addCurveData(curveTimeStepsY, curveValuesY);
curveMerger.computeInterpolatedValues();
if (curveMerger.allTimeSteps().size() > 0)
if (curveMerger.allXValues().size() > 0)
{
m_qwtPlotCurve->setSamplesFromXValuesAndYValues(curveMerger.interpolatedCurveValuesForAllTimeSteps(0),
curveMerger.interpolatedCurveValuesForAllTimeSteps(1),
m_qwtPlotCurve->setSamplesFromXValuesAndYValues(curveMerger.interpolatedYValuesForAllXValues(0),
curveMerger.interpolatedYValuesForAllXValues(1),
isLogCurve);
}
else
@@ -995,11 +995,11 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
if (!curveValuesX.empty() && !curveValuesY.empty())
{
RiaTimeHistoryCurveMerger curveMerger;
curveMerger.addCurveData(curveValuesX, curveTimeStepsX);
curveMerger.addCurveData(curveValuesY, curveTimeStepsY);
curveMerger.addCurveData(curveTimeStepsX, curveValuesX);
curveMerger.addCurveData(curveTimeStepsY, curveValuesY);
curveMerger.computeInterpolatedValues();
if (curveMerger.validIntervalsForAllTimeSteps().size() == 0)
if (curveMerger.validIntervalsForAllXValues().size() == 0)
{
QString description;