#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

@ -903,8 +903,29 @@ void RivReservoirViewPartMgr::updateFaultCellEdgeResultColor(RivCellSetEnum geom
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::UByteArray* RivReservoirViewPartMgr::cellVisibility(RivCellSetEnum geometryType, size_t gridIndex, size_t timeStepIndex) const
const cvf::UByteArray* RivReservoirViewPartMgr::cellVisibility(RivCellSetEnum geometryType, size_t gridIndex, size_t timeStepIndex)
{
if (geometryType == PROPERTY_FILTERED)
{
if (timeStepIndex >= m_propFilteredGeometryFramesNeedsRegen.size() || m_propFilteredGeometryFramesNeedsRegen[timeStepIndex])
{
createPropertyFilteredNoneWellCellGeometry(timeStepIndex);
}
}
else if (geometryType == PROPERTY_FILTERED_WELL_CELLS)
{
if (timeStepIndex >= m_propFilteredWellGeometryFramesNeedsRegen.size() || m_propFilteredWellGeometryFramesNeedsRegen[timeStepIndex])
{
createPropertyFilteredWellGeometry(timeStepIndex);
}
}
else
{
if (m_geometriesNeedsRegen[geometryType])
{
createGeometry(geometryType);
}
}
RivReservoirPartMgr * pmgr = (const_cast<RivReservoirViewPartMgr*>(this))->reservoirPartManager( geometryType, timeStepIndex );
return pmgr->cellVisibility(gridIndex).p();
}

View File

@ -52,7 +52,7 @@ public:
void clearGeometryCache();
void scheduleGeometryRegen(RivCellSetEnum geometryType);
const cvf::UByteArray* cellVisibility(RivCellSetEnum geometryType, size_t gridIndex, size_t frameIndex) const;
const cvf::UByteArray* cellVisibility(RivCellSetEnum geometryType, size_t gridIndex, size_t frameIndex);
void appendStaticGeometryPartsToModel (cvf::ModelBasicList* model, RivCellSetEnum geometryType, const std::vector<size_t>& gridIndices);
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex, const std::vector<size_t>& gridIndices);

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;

View File

@ -1248,6 +1248,14 @@ const RivReservoirViewPartMgr* RimEclipseView::reservoirGridPartManager() const
return m_reservoirGridPartManager.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivReservoirViewPartMgr * RimEclipseView::reservoirGridPartManager()
{
return m_reservoirGridPartManager.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1599,7 +1607,7 @@ void RimEclipseView::setOverridePropertyFilterCollection(RimEclipsePropertyFilte
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseView::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility)
void RimEclipseView::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep)
{
size_t gridCount = this->eclipseCase()->eclipseCaseData()->gridCount();
size_t cellCount = this->mainGrid()->globalCellArray().size();
@ -1614,7 +1622,7 @@ void RimEclipseView::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalV
for (size_t gpIdx = 0; gpIdx < m_visibleGridParts.size(); ++gpIdx)
{
const cvf::UByteArray* visibility = m_reservoirGridPartManager->cellVisibility(m_visibleGridParts[gpIdx], gridIdx, m_currentTimeStep);
const cvf::UByteArray* visibility = m_reservoirGridPartManager->cellVisibility(m_visibleGridParts[gpIdx], gridIdx, timeStep);
for (int lcIdx = 0; lcIdx < gridCellCount; ++ lcIdx)
{

View File

@ -136,6 +136,7 @@ public:
const std::vector<RivCellSetEnum>& visibleGridParts() const;
const RivReservoirViewPartMgr* reservoirGridPartManager() const;
RivReservoirViewPartMgr* reservoirGridPartManager();
// Does this belong here, really ?
void calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid);
@ -148,6 +149,8 @@ public:
virtual bool isUsingFormationNames() const override;
virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) override;
protected:
virtual void initAfterRead();
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
@ -178,7 +181,6 @@ private:
void clampCurrentTimestep();
virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility);
caf::PdmChildField<RimEclipsePropertyFilterCollection*> m_propertyFilterCollection;
caf::PdmPointer<RimEclipsePropertyFilterCollection> m_overridePropertyFilterCollection;

View File

@ -280,7 +280,7 @@ bool RimEclipseWell::intersectsWellCellsFilteredCells(const RigWellResultFrame &
if (!reservoirView) return false;
const std::vector<RivCellSetEnum>& visGridParts = reservoirView->visibleGridParts();
const RivReservoirViewPartMgr* rvMan = reservoirView->reservoirGridPartManager();
RivReservoirViewPartMgr* rvMan = reservoirView->reservoirGridPartManager();
for (const RivCellSetEnum& visGridPart : visGridParts)

View File

@ -573,9 +573,9 @@ const RimGeoMechPropertyFilterCollection* RimGeoMechView::geoMechPropertyFilterC
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility)
void RimGeoMechView::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep)
{
m_vizLogic->calculateCurrentTotalCellVisibility(totalVisibility, m_currentTimeStep);
m_vizLogic->calculateCurrentTotalCellVisibility(totalVisibility, timeStep);
}
//--------------------------------------------------------------------------------------------------

View File

@ -84,6 +84,8 @@ public:
virtual bool isUsingFormationNames() const override;
virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) override;
protected:
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "");
@ -106,7 +108,6 @@ private:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void initAfterRead();
virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility);
caf::PdmChildField<RimGeoMechPropertyFilterCollection*> m_propertyFilterCollection;

View File

@ -874,7 +874,7 @@ cvf::ref<cvf::UByteArray> RimView::currentTotalCellVisibility()
if (m_currentReservoirCellVisibility.isNull())
{
m_currentReservoirCellVisibility = new cvf::UByteArray;
this->calculateCurrentTotalCellVisibility(m_currentReservoirCellVisibility.p());
this->calculateCurrentTotalCellVisibility(m_currentReservoirCellVisibility.p(), m_currentTimeStep());
}
return m_currentReservoirCellVisibility;

View File

@ -203,7 +203,7 @@ protected:
virtual cvf::Transform* scaleTransform() = 0;
virtual void resetLegendsInViewer() = 0;
virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility) = 0;
virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0;
RimWellPathCollection* wellPathsPartManager();

View File

@ -37,6 +37,7 @@ namespace caf
void RigFlowDiagResults::CellFilterEnum::setUp()
{
addItem(RigFlowDiagResults::CELLS_ACTIVE, "CELLS_ACTIVE", "All Active Cells");
addItem(RigFlowDiagResults::CELLS_VISIBLE, "CELLS_VISIBLE", "Visible Cells");
addItem(RigFlowDiagResults::CELLS_COMMUNICATION, "CELLS_COMMUNICATION", "Injector Producer Communication");
addItem(RigFlowDiagResults::CELLS_FLOODED, "CELLS_FLOODED", "Flooded by Injector");
addItem(RigFlowDiagResults::CELLS_DRAINED, "CELLS_DRAINED", "Drained by Producer");
@ -798,3 +799,51 @@ RigFlowDiagSolverInterface::FlowCharacteristicsResultFrame RigFlowDiagResults::f
return solverInterface()->calculateFlowCharacteristics(&injectorResults, &producerResults, selectedCellIndices, max_pv_fraction);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFlowDiagSolverInterface::FlowCharacteristicsResultFrame RigFlowDiagResults::flowCharacteristicsResults(int frameIndex,
const std::vector<char>& visibleActiveCells,
double max_pv_fraction)
{
std::vector<QString> tracerNames = m_flowDiagSolution->tracerNames();
std::set<std::string> injectorNames;
std::set<std::string> producerNames;
for (const QString& tracerName : tracerNames)
{
RimFlowDiagSolution::TracerStatusType status = m_flowDiagSolution->tracerStatusInTimeStep(tracerName, frameIndex);
if (status == RimFlowDiagSolution::INJECTOR)
{
injectorNames.insert(tracerName.toStdString());
}
else if (status == RimFlowDiagSolution::PRODUCER)
{
producerNames.insert(tracerName.toStdString());
}
}
RigFlowDiagResultAddress injectorAddress(RIG_FLD_TOF_RESNAME, RigFlowDiagResultAddress::PHASE_ALL, injectorNames);
RigFlowDiagResultAddress producerAddress(RIG_FLD_TOF_RESNAME, RigFlowDiagResultAddress::PHASE_ALL, producerNames);
const std::vector<double>* allInjectorResults = resultValues(injectorAddress, frameIndex);
const std::vector<double>* allProducerResults = resultValues(producerAddress, frameIndex);
std::vector<size_t> selectedCellIndices;
std::vector<double> injectorResults;
std::vector<double> producerResults;
for (size_t i = 0; i < visibleActiveCells.size(); ++i)
{
if (visibleActiveCells[i])
{
selectedCellIndices.push_back(i);
injectorResults.push_back(allInjectorResults->at(i));
producerResults.push_back(allProducerResults->at(i));
}
}
return solverInterface()->calculateFlowCharacteristics(&injectorResults, &producerResults, selectedCellIndices, max_pv_fraction);
}

View File

@ -28,6 +28,7 @@
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfArray.h"
#include <vector>
#include <map>
@ -44,9 +45,10 @@ public:
enum CellFilter
{
CELLS_ACTIVE,
CELLS_VISIBLE,
CELLS_COMMUNICATION,
CELLS_FLOODED,
CELLS_DRAINED
CELLS_DRAINED,
};
typedef caf::AppEnum<CellFilter> CellFilterEnum;
@ -84,6 +86,10 @@ public:
const std::vector<QString>& tracerNames,
double max_pv_fraction);
RigFlowDiagSolverInterface::FlowCharacteristicsResultFrame flowCharacteristicsResults(int frameIndex,
const std::vector<char>& visibleActiveCells,
double max_pv_fraction);
private:
const std::vector<double>* findOrCalculateResult (const RigFlowDiagResultAddress& resVarAddr, size_t frameIndex);
void calculateNativeResultsIfNotPreviouslyAttempted(size_t frameIndex, RigFlowDiagResultAddress::PhaseSelection phaseSelection);