#1807 Add option to use visible cells in view as region selection in flow characteristics plot

This commit is contained in:
Bjørnar Grip Fjær
2017-08-24 09:27:08 +02:00
parent ee5a2530fd
commit 5ead49e01e
13 changed files with 173 additions and 18 deletions

View File

@@ -19,6 +19,8 @@
#include "RimFlowCharacteristicsPlot.h"
#include "RigFlowDiagResults.h"
#include "RigEclipseCaseData.h"
#include "RigActiveCellInfo.h"
#include "RimEclipseResultCase.h"
#include "RimFlowDiagSolution.h"
@@ -85,6 +87,7 @@ RimFlowCharacteristicsPlot::RimFlowCharacteristicsPlot()
// Region group
CAF_PDM_InitFieldNoDefault(&m_cellFilter, "CellFilter", "Cell Filter", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_cellFilterView, "CellFilterView", "View", "", "", "");
CAF_PDM_InitField(&m_tracerFilter, "TracerFilter", QString(), "Tracer Filter", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_selectedTracerNames, "SelectedTracerNames", " ", "", "", "");
m_selectedTracerNames.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
@@ -118,12 +121,17 @@ void RimFlowCharacteristicsPlot::setFromFlowSolution(RimFlowDiagSolution* flowSo
if ( !flowSolution )
{
m_case = nullptr;
m_cellFilterView = nullptr;
}
else
{
RimEclipseResultCase* eclCase;
flowSolution->firstAncestorOrThisOfType(eclCase);
m_case = eclCase;
if (!eclCase->reservoirViews.empty())
{
m_cellFilterView = eclCase->reservoirViews()[0];
}
}
m_flowDiagSolution = flowSolution;
@@ -184,6 +192,16 @@ QList<caf::PdmOptionItemInfo> RimFlowCharacteristicsPlot::calculateValueOptions(
}
}
}
else if ( fieldNeedingOptions == &m_cellFilterView )
{
if ( m_case )
{
for (RimEclipseView* view : m_case()->reservoirViews())
{
options.push_back(caf::PdmOptionItemInfo(view->name(), view, false, view->uiIcon()));
}
}
}
else if ( fieldNeedingOptions == &m_flowDiagSolution )
{
if ( m_case )
@@ -307,6 +325,10 @@ void RimFlowCharacteristicsPlot::defineUiOrdering(QString uiConfigName, caf::Pdm
{
m_case = defaultCase;
m_flowDiagSolution = m_case->defaultFlowDiagSolution();
if (!m_case()->reservoirViews.empty())
{
m_cellFilterView = m_case()->reservoirViews()[0];
}
}
}
}
@@ -328,12 +350,18 @@ void RimFlowCharacteristicsPlot::defineUiOrdering(QString uiConfigName, caf::Pdm
{
caf::PdmUiGroup* regionGroup = uiOrdering.addNewGroup("Region");
regionGroup->add(&m_cellFilter);
if (m_cellFilter() != RigFlowDiagResults::CELLS_ACTIVE)
if (m_cellFilter() == RigFlowDiagResults::CELLS_COMMUNICATION ||
m_cellFilter() == RigFlowDiagResults::CELLS_DRAINED ||
m_cellFilter() == RigFlowDiagResults::CELLS_FLOODED)
{
regionGroup->add(&m_tracerFilter);
regionGroup->add(&m_selectedTracerNames);
regionGroup->add(&m_showRegion);
}
else if (m_cellFilter() == RigFlowDiagResults::CELLS_VISIBLE)
{
regionGroup->add(&m_cellFilterView);
}
}
{
@@ -395,8 +423,12 @@ void RimFlowCharacteristicsPlot::fieldChangedByUi(const caf::PdmFieldHandle* cha
if ( &m_case == changedField )
{
m_flowDiagSolution = m_case->defaultFlowDiagSolution();
m_currentlyPlottedTimeSteps.clear();
m_flowDiagSolution = m_case->defaultFlowDiagSolution();
m_currentlyPlottedTimeSteps.clear();
if (!m_case()->reservoirViews.empty())
{
m_cellFilterView = m_case()->reservoirViews()[0];
}
}
else if (&m_applyTimeSteps == changedField)
{
@@ -538,16 +570,50 @@ void RimFlowCharacteristicsPlot::loadDataAndUpdate()
}
}
for ( int timeStepIdx: calculatedTimesteps )
std::map<int, RigFlowDiagSolverInterface::FlowCharacteristicsResultFrame> timeStepToFlowResultMap;
for (int timeStepIdx : calculatedTimesteps)
{
lorenzVals[timeStepIdx] = flowResult->flowCharacteristicsResults(timeStepIdx, m_cellFilter(), selectedTracerNames, m_maxPvFraction()).m_lorenzCoefficient;
if (m_cellFilter() == RigFlowDiagResults::CELLS_VISIBLE)
{
cvf::UByteArray visibleCells;
m_case()->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL);
if (m_cellFilterView)
{
m_cellFilterView()->calculateCurrentTotalCellVisibility(&visibleCells, timeStepIdx);
}
RigActiveCellInfo* activeCellInfo = m_case()->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL);
std::vector<char> visibleActiveCells(activeCellInfo->reservoirActiveCellCount(), 0);
for (size_t i = 0; i < visibleCells.size(); ++i)
{
size_t cellIndex = activeCellInfo->cellResultIndex(i);
if (cellIndex != cvf::UNDEFINED_SIZE_T)
{
visibleActiveCells[cellIndex] = visibleCells[i];
}
}
auto flowCharResults = flowResult->flowCharacteristicsResults(timeStepIdx, visibleActiveCells, m_maxPvFraction());
timeStepToFlowResultMap[timeStepIdx] = flowCharResults;
}
else
{
auto flowCharResults = flowResult->flowCharacteristicsResults(timeStepIdx, m_cellFilter(), selectedTracerNames, m_maxPvFraction());
timeStepToFlowResultMap[timeStepIdx] = flowCharResults;
}
lorenzVals[timeStepIdx] = timeStepToFlowResultMap[timeStepIdx].m_lorenzCoefficient;
}
m_flowCharPlotWidget->setLorenzCurve(timeStepStrings, timeStepDates, lorenzVals);
for ( int timeStepIdx: calculatedTimesteps )
{
const auto flowCharResults = flowResult->flowCharacteristicsResults(timeStepIdx, m_cellFilter(), selectedTracerNames, m_maxPvFraction());
const auto& flowCharResults = timeStepToFlowResultMap[timeStepIdx];
m_flowCharPlotWidget->addFlowCapStorageCapCurve(timeStepDates[timeStepIdx],
flowCharResults.m_flowCapStorageCapCurve.first,
flowCharResults.m_flowCapStorageCapCurve.second);

View File

@@ -31,6 +31,7 @@
class RimFlowDiagSolution;
class RimEclipseResultCase;
class RimEclipseView;
class RiuFlowCharacteristicsPlot;
@@ -96,6 +97,7 @@ private:
caf::PdmField<double> m_maxPvFraction;
caf::PdmField<RigFlowDiagResults::CellFilterEnum> m_cellFilter;
caf::PdmPtrField<RimEclipseView*> m_cellFilterView;
caf::PdmField<QString> m_tracerFilter;
caf::PdmField< std::vector<QString> > m_selectedTracerNames;
caf::PdmField<bool> m_showRegion;