#4571 Sum. cmd. line: Add support for -s, -n and -e to grid cell plotting

This commit is contained in:
Jacob Støren
2019-08-22 08:34:49 +02:00
committed by Gaute Lindkvist
parent 889577400a
commit 11e73a76fc
4 changed files with 114 additions and 21 deletions

View File

@@ -53,6 +53,8 @@
#include "RimOilField.h" #include "RimOilField.h"
#include "RimEclipseCaseCollection.h" #include "RimEclipseCaseCollection.h"
#include "RigEclipseResultAddress.h" #include "RigEclipseResultAddress.h"
#include "RigEclipseCaseData.h"
#include "RigCaseCellResultsData.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@@ -590,32 +592,100 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine(const QString
RimSummaryPlotCollection* sumPlotColl = RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection(); RimSummaryPlotCollection* sumPlotColl = RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
for (const QString& gridAddressFilter : gridResultAddressFilters) if ( isSinglePlot )
{ {
std::vector<RigGridCellResultAddress> cellResAddrs = createGridCellAddressesFromFilter(gridAddressFilter); std::vector<RimGridTimeHistoryCurve*> createdCurves;
for (RigGridCellResultAddress cellResAddr : cellResAddrs ) int curveColorIndex = 0;
for ( const QString& gridAddressFilter : gridResultAddressFilters )
{
std::vector<RigGridCellResultAddress> cellResAddrs = createGridCellAddressesFromFilter(gridAddressFilter);
for ( RigGridCellResultAddress cellResAddr : cellResAddrs )
{
for ( RimEclipseCase* eclCase: gridCasesToPlotFrom )
{
if (!(eclCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL) &&
eclCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->resultInfo(cellResAddr.eclipseResultAddress)) )
{
RiaLogging::warning("Could not find a restart result property with name: \"" + cellResAddr.eclipseResultAddress.m_resultName + "\"");
continue;
}
RimGridTimeHistoryCurve* newCurve = new RimGridTimeHistoryCurve();
newCurve->setFromEclipseCellAndResult(eclCase,
cellResAddr.gridIndex,
cellResAddr.i,
cellResAddr.j,
cellResAddr.k,
cellResAddr.eclipseResultAddress);
newCurve->setLineThickness(2);
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(curveColorIndex);
newCurve->setColor(curveColor);
if (!isEnsembleMode) ++curveColorIndex;
createdCurves.push_back(newCurve);
}
if (isEnsembleMode) ++curveColorIndex;
}
}
if ( createdCurves.size() )
{ {
RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle(); RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle();
for ( RimEclipseCase* eclCase: gridCasesToPlotFrom ) for ( auto curve: createdCurves )
{ {
RimGridTimeHistoryCurve* newCurve = new RimGridTimeHistoryCurve(); newPlot->addGridTimeHistoryCurve(curve);
newCurve->setFromEclipseCellAndResult(eclCase, }
cellResAddr.gridIndex,
cellResAddr.i,
cellResAddr.j,
cellResAddr.k,
cellResAddr.eclipseResultAddress);
newCurve->setLineThickness(2);
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(newPlot->curveCount());
newCurve->setColor(curveColor);
newPlot->addGridTimeHistoryCurve(newCurve); newPlot->showLegend(!hideLegend);
newPlot->setNormalizationEnabled(isNormalizedY);
newPlot->loadDataAndUpdate();
}
}
else // Multiplot
{
int curveColorIndex = 0;
newPlot->showLegend(!hideLegend); for ( const QString& gridAddressFilter : gridResultAddressFilters )
newPlot->setNormalizationEnabled(isNormalizedY); {
std::vector<RigGridCellResultAddress> cellResAddrs = createGridCellAddressesFromFilter(gridAddressFilter);
for ( RigGridCellResultAddress cellResAddr : cellResAddrs )
{
std::vector<RimGridTimeHistoryCurve*> createdCurves;
for ( RimEclipseCase* eclCase: gridCasesToPlotFrom )
{
if (!(eclCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL) &&
eclCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->resultInfo(cellResAddr.eclipseResultAddress)) )
{
RiaLogging::warning("Could not find a restart result property with name: \"" + cellResAddr.eclipseResultAddress.m_resultName + "\"");
continue;
}
RimGridTimeHistoryCurve* newCurve = new RimGridTimeHistoryCurve();
newCurve->setFromEclipseCellAndResult(eclCase,
cellResAddr.gridIndex,
cellResAddr.i,
cellResAddr.j,
cellResAddr.k,
cellResAddr.eclipseResultAddress);
newCurve->setLineThickness(2);
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(curveColorIndex);
newCurve->setColor(curveColor);
if (!isEnsembleMode) ++curveColorIndex;
createdCurves.push_back(newCurve);
}
newPlot->applyDefaultCurveAppearances(); if (isEnsembleMode) ++curveColorIndex;
newPlot->loadDataAndUpdate();
if ( createdCurves.size() )
{
RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle();
for (auto newCurve : createdCurves)
{
newPlot->addGridTimeHistoryCurve(newCurve);
}
newPlot->showLegend(!hideLegend);
newPlot->setNormalizationEnabled(isNormalizedY);
newPlot->loadDataAndUpdate();
}
} }
} }
} }

View File

@@ -769,7 +769,8 @@ void RimEclipseResultDefinition::setFromEclipseResultAddress(const RigEclipseRes
const RigCaseCellResultsData* gridCellResults = this->currentGridCellResults(); const RigCaseCellResultsData* gridCellResults = this->currentGridCellResults();
if (gridCellResults) if (gridCellResults)
{ {
canonizedAddress = gridCellResults->resultInfo(address)->eclipseResultAddress(); auto rinfo = gridCellResults->resultInfo(address);
if (rinfo) canonizedAddress = rinfo->eclipseResultAddress();
} }
m_resultType = canonizedAddress.m_resultCatType; m_resultType = canonizedAddress.m_resultCatType;

View File

@@ -214,6 +214,22 @@ std::vector<double> RimGridTimeHistoryCurve::yValues() const
} }
} }
RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfTypeAsserted(plot);
bool isNormalized = plot->isNormalizationEnabled();
if (isNormalized)
{
auto minMaxPair = std::minmax_element(values.begin(), values.end());
double min = *minMaxPair.first;
double max = *minMaxPair.second;
double range = max - min;
for (double & v: values)
{
v = (v - min)/range;
}
}
return values; return values;
} }

View File

@@ -991,7 +991,13 @@ std::vector<RigEclipseResultAddress> RigCaseCellResultsData::existingResults() c
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const RigEclipseResultInfo* RigCaseCellResultsData::resultInfo(const RigEclipseResultAddress& resVarAddr) const const RigEclipseResultInfo* RigCaseCellResultsData::resultInfo(const RigEclipseResultAddress& resVarAddr) const
{ {
return &(m_resultInfos[findScalarResultIndexFromAddress(resVarAddr)]); size_t index = findScalarResultIndexFromAddress(resVarAddr);
if (index < m_resultInfos.size())
{
return &(m_resultInfos[index]);
}
return nullptr;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------