mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1035 Connected the Flow Diag solver, and added the statistics needed for legend. Now many things work .
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include "RimReservoirCellResultsStorage.h"
|
||||
#include "RimTools.h"
|
||||
#include "RimFlowDiagSolution.h"
|
||||
#include "RigFlowDiagSolverInterface.h"
|
||||
|
||||
#include "cafPdmSettings.h"
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
@@ -71,6 +72,8 @@ RimEclipseResultCase::RimEclipseResultCase()
|
||||
flipYAxis.xmlCapability()->setIOWritable(true);
|
||||
//flipYAxis.uiCapability()->setUiHidden(true);
|
||||
|
||||
m_flowDagSolverInterface = new RigFlowDiagSolverInterface(this);
|
||||
|
||||
m_activeCellInfoIsReadFromFile = false;
|
||||
m_gridAndWellDataIsReadFromFile = false;
|
||||
}
|
||||
@@ -357,6 +360,14 @@ std::vector<RimFlowDiagSolution*> RimEclipseResultCase::flowDiagSolutions()
|
||||
return flowSols;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigFlowDiagSolverInterface* RimEclipseResultCase::flowDiagSolverInterface()
|
||||
{
|
||||
return m_flowDagSolverInterface.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
class RifReaderInterface;
|
||||
class RigMainGrid;
|
||||
class RimFlowDiagSolution;
|
||||
class RigFlowDiagSolverInterface;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@@ -52,6 +53,8 @@ public:
|
||||
virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath);
|
||||
|
||||
std::vector<RimFlowDiagSolution*> flowDiagSolutions();
|
||||
RigFlowDiagSolverInterface* flowDiagSolverInterface();
|
||||
|
||||
private:
|
||||
cvf::ref<RifReaderInterface> createMockModel(QString modelName);
|
||||
|
||||
@@ -59,6 +62,8 @@ private:
|
||||
|
||||
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
|
||||
|
||||
cvf::ref<RigFlowDiagSolverInterface> m_flowDagSolverInterface;
|
||||
|
||||
// Fields:
|
||||
caf::PdmField<QString> caseFileName;
|
||||
caf::PdmChildArrayField<RimFlowDiagSolution*> m_flowDiagSolutions;
|
||||
|
||||
@@ -76,6 +76,9 @@
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <limits.h>
|
||||
#include "RimEclipseResultDefinition.h"
|
||||
#include "RimFlowDiagSolution.h"
|
||||
#include "RigFlowDiagResults.h"
|
||||
|
||||
|
||||
|
||||
@@ -947,6 +950,7 @@ void RimEclipseView::updateLegends()
|
||||
CVF_ASSERT(results);
|
||||
|
||||
updateMinMaxValuesAndAddLegendToView(QString("Cell Results: \n"), this->cellResult(), results);
|
||||
|
||||
if (this->faultResultSettings()->showCustomFaultResult() && this->faultResultSettings()->hasValidCustomResult())
|
||||
{
|
||||
updateMinMaxValuesAndAddLegendToView(QString("Fault Results: \n"), this->currentFaultResultColors(), results);
|
||||
@@ -994,7 +998,43 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, R
|
||||
{
|
||||
if (resultColors->resultType() == RimDefines::FLOW_DIAGNOSTICS)
|
||||
{
|
||||
// Todo
|
||||
double globalMin, globalMax;
|
||||
double globalPosClosestToZero, globalNegClosestToZero;
|
||||
RigFlowDiagResults* cellResultsData = resultColors->flowDiagSolution()->flowDiagResults();
|
||||
RigFlowDiagResultAddress resAddr = resultColors->flowDiagResAddress();
|
||||
|
||||
cellResultsData->minMaxScalarValues(resAddr, m_currentTimeStep, &globalMin, &globalMax);
|
||||
cellResultsData->posNegClosestToZero(resAddr, m_currentTimeStep, &globalPosClosestToZero, &globalNegClosestToZero);
|
||||
|
||||
double localMin, localMax;
|
||||
double localPosClosestToZero, localNegClosestToZero;
|
||||
if ( resultColors->hasDynamicResult() )
|
||||
{
|
||||
cellResultsData->minMaxScalarValues(resAddr, m_currentTimeStep, &localMin, &localMax);
|
||||
cellResultsData->posNegClosestToZero(resAddr, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero);
|
||||
}
|
||||
else
|
||||
{
|
||||
localMin = globalMin;
|
||||
localMax = globalMax;
|
||||
|
||||
localPosClosestToZero = globalPosClosestToZero;
|
||||
localNegClosestToZero = globalNegClosestToZero;
|
||||
}
|
||||
|
||||
CVF_ASSERT(resultColors->legendConfig());
|
||||
|
||||
resultColors->legendConfig()->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
|
||||
resultColors->legendConfig()->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
|
||||
|
||||
if ( resultColors->hasCategoryResult() )
|
||||
{
|
||||
resultColors->legendConfig()->setIntegerCategories(cellResultsData->uniqueCellScalarValues(resAddr, m_currentTimeStep));
|
||||
}
|
||||
|
||||
m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend());
|
||||
resultColors->legendConfig()->setTitle(cvfqt::Utils::toString(legendLabel + resultColors->resultVariable()));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "RigCaseData.h"
|
||||
|
||||
#include "RigFlowDiagResults.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimFlowDiagSolution, "FlowDiagSolution");
|
||||
|
||||
@@ -94,6 +95,82 @@ std::set<QString> RimFlowDiagSolution::tracerNames()
|
||||
return tracerNameSet;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<std::string, std::vector<int> > RimFlowDiagSolution::allInjectorTracerActiveCellIndices(size_t timeStepIndex)
|
||||
{
|
||||
return allTracerActiveCellIndices(timeStepIndex, true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<std::string, std::vector<int> > RimFlowDiagSolution::allProducerTracerActiveCellIndices(size_t timeStepIndex)
|
||||
{
|
||||
return allTracerActiveCellIndices(timeStepIndex, false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<std::string, std::vector<int> > RimFlowDiagSolution::allTracerActiveCellIndices(size_t timeStepIndex, bool useInjectors)
|
||||
{
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfType(eclCase);
|
||||
TracerStatusType tracerStatus = UNDEFINED;
|
||||
|
||||
std::map<std::string, std::vector<int> > tracersWithCells;
|
||||
|
||||
if ( eclCase )
|
||||
{
|
||||
const cvf::Collection<RigSingleWellResultsData>& wellResults = eclCase->reservoirData()->wellResults();
|
||||
RigMainGrid* mainGrid = eclCase->reservoirData()->mainGrid();
|
||||
RigActiveCellInfo* activeCellInfo = eclCase->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS); //Todo: Must come from the results definition
|
||||
|
||||
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
|
||||
{
|
||||
if (!wellResults[wIdx]->hasWellResult(timeStepIndex) ) continue;
|
||||
|
||||
size_t wellTimeStep = wellResults[wIdx]->m_resultTimeStepIndexToWellTimeStepIndex[timeStepIndex];
|
||||
const RigWellResultFrame& wellResFrame = wellResults[wIdx]->m_wellCellsTimeSteps[wellTimeStep];
|
||||
|
||||
if ( !wellResFrame.m_isOpen ) continue;
|
||||
|
||||
bool useWell = ( useInjectors && ( wellResFrame.m_productionType == RigWellResultFrame::GAS_INJECTOR
|
||||
|| wellResFrame.m_productionType == RigWellResultFrame::OIL_INJECTOR
|
||||
|| wellResFrame.m_productionType == RigWellResultFrame::WATER_INJECTOR) )
|
||||
|| (!useInjectors && wellResFrame.m_productionType == RigWellResultFrame::PRODUCER);
|
||||
|
||||
|
||||
if (useWell)
|
||||
{
|
||||
std::string wellname = wellResults[wIdx]->m_wellName.toStdString();
|
||||
std::vector<int>& tracerCells = tracersWithCells[wellname];
|
||||
|
||||
for (const RigWellResultBranch& wBr: wellResFrame.m_wellResultBranches)
|
||||
{
|
||||
for (const RigWellResultPoint& wrp: wBr.m_branchResultPoints)
|
||||
{
|
||||
if (wrp.isValid() && wrp.m_isOpen)
|
||||
{
|
||||
RigGridBase * grid = mainGrid->gridByIndex(wrp.m_gridIndex);
|
||||
size_t reservoirCellIndex = grid->reservoirCellIndex(wrp.m_gridCellIndex);
|
||||
|
||||
int cellActiveIndex = static_cast<int>(activeCellInfo->cellResultIndex(reservoirCellIndex));
|
||||
tracerCells.push_back(cellActiveIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tracersWithCells;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -40,6 +40,9 @@ public:
|
||||
RigFlowDiagResults* flowDiagResults();
|
||||
std::set<QString> tracerNames();
|
||||
|
||||
std::map<std::string, std::vector<int> > allInjectorTracerActiveCellIndices(size_t timeStepIndex);
|
||||
std::map<std::string, std::vector<int> > allProducerTracerActiveCellIndices(size_t timeStepIndex);
|
||||
|
||||
enum TracerStatusType
|
||||
{
|
||||
PRODUCER,
|
||||
@@ -50,10 +53,13 @@ public:
|
||||
|
||||
TracerStatusType tracerStatus(QString tracerName);
|
||||
|
||||
|
||||
protected:
|
||||
//virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
||||
|
||||
private:
|
||||
std::map<std::string, std::vector<int> > allTracerActiveCellIndices(size_t timeStepIndex, bool useInjectors);
|
||||
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() override;
|
||||
caf::PdmField<QString> m_userDescription;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user