mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Improved statistical data infrastructure
p4#: 20694
This commit is contained in:
parent
42f3f0b2d2
commit
4c955ece4a
@ -44,9 +44,6 @@ RifReaderStatisticalCalculation::~RifReaderStatisticalCalculation()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifReaderStatisticalCalculation::open(const QString& fileName, RigEclipseCase* eclipseCase)
|
||||
{
|
||||
m_matrixDynamicResultNames.push_back("SOIL");
|
||||
m_matrixDynamicResultNames.push_back("PRESSURE");
|
||||
|
||||
buildMetaData(eclipseCase);
|
||||
|
||||
return true;
|
||||
@ -119,3 +116,19 @@ void RifReaderStatisticalCalculation::setTimeSteps(const QList<QDateTime>& times
|
||||
m_timeSteps = timesteps;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifReaderStatisticalCalculation::staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifReaderStatisticalCalculation::dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,8 @@ public:
|
||||
|
||||
virtual void close() {}
|
||||
|
||||
virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values ) { return false; }
|
||||
virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values ) { return false; }
|
||||
virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values );
|
||||
virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values );
|
||||
|
||||
void setMatrixResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames);
|
||||
void setFractureResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames);
|
||||
|
@ -274,7 +274,7 @@ void RimReservoirView::clampCurrentTimestep()
|
||||
// Clamp the current timestep to actual possibilities
|
||||
if (this->gridCellResults())
|
||||
{
|
||||
if (m_currentTimeStep() > this->gridCellResults()->maxTimeStepCount())
|
||||
if (m_currentTimeStep() > static_cast<int>(this->gridCellResults()->maxTimeStepCount()))
|
||||
{
|
||||
m_currentTimeStep = static_cast<int>(this->gridCellResults()->maxTimeStepCount()) -1;
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "RigEclipseCase.h"
|
||||
#include "RifReaderStatisticalCalculation.h"
|
||||
#include "RigReservoirCellResults.h"
|
||||
#include "RigStatistics.h"
|
||||
#include "RigMainGrid.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimStatisticalCalculation, "RimStatisticalCalculation");
|
||||
@ -35,12 +37,16 @@ CAF_PDM_SOURCE_INIT(RimStatisticalCalculation, "RimStatisticalCalculation");
|
||||
RimStatisticalCalculation::RimStatisticalCalculation()
|
||||
: RimReservoir()
|
||||
{
|
||||
CAF_PDM_InitField(&m_resultName, "ResultName", QString("PRESSURE"), "ResultName", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&statisticsMin, "StatisticsMin", true, "Minimum", "", "" ,"");
|
||||
CAF_PDM_InitField(&statisticsMax, "StatisticsMax", true, "Maximum", "", "" ,"");
|
||||
CAF_PDM_InitField(&statisticsMean, "StatisticsMean", true, "Mean", "", "" ,"");
|
||||
CAF_PDM_InitField(&statisticsStdDev, "StatisticsStdDev", true, "Std dev", "", "" ,"");
|
||||
|
||||
m_readerInterface = new RifReaderStatisticalCalculation;
|
||||
|
||||
openEclipseGridFile();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -51,11 +57,25 @@ RimStatisticalCalculation::~RimStatisticalCalculation()
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticalCalculation::setMainGrid(RigMainGrid* mainGrid)
|
||||
{
|
||||
CVF_ASSERT(mainGrid);
|
||||
CVF_ASSERT(m_rigEclipseCase.notNull());
|
||||
|
||||
m_rigEclipseCase->setMainGrid(mainGrid);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimStatisticalCalculation::openEclipseGridFile()
|
||||
{
|
||||
if (m_rigEclipseCase.notNull()) return true;
|
||||
|
||||
cvf::ref<RigEclipseCase> eclipseCase = new RigEclipseCase;
|
||||
|
||||
if (!m_readerInterface->open("dummy", eclipseCase.p()))
|
||||
@ -115,25 +135,30 @@ RimStatisticalCollection* RimStatisticalCalculation::parent()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticalCalculation::computeStatistics()
|
||||
{
|
||||
if (statisticsMin)
|
||||
if (m_rigEclipseCase.isNull())
|
||||
{
|
||||
createAndComputeMin();
|
||||
}
|
||||
|
||||
if (statisticsMax)
|
||||
{
|
||||
createAndComputeMax();
|
||||
openEclipseGridFile();
|
||||
}
|
||||
|
||||
if (statisticsMean)
|
||||
cvf::Collection<RigEclipseCase> sourceCases;
|
||||
|
||||
getSourceCases(sourceCases);
|
||||
|
||||
if (sourceCases.size() == 0)
|
||||
{
|
||||
createAndComputeMean();
|
||||
return;
|
||||
}
|
||||
|
||||
if (statisticsStdDev)
|
||||
{
|
||||
createAndComputeStdDev();
|
||||
}
|
||||
RigStatisticsConfig statisticsConfig;
|
||||
|
||||
std::vector<size_t> timeStepIndices;
|
||||
timeStepIndices.push_back(0);
|
||||
timeStepIndices.push_back(1);
|
||||
|
||||
RigEclipseCase* resultCase = reservoirData();
|
||||
|
||||
RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase);
|
||||
stat.evaluateStatistics(RimDefines::DYNAMIC_NATIVE, m_resultName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -167,3 +192,50 @@ void RimStatisticalCalculation::createAndComputeStdDev()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticalCalculation::getSourceCases(cvf::Collection<RigEclipseCase>& sourceCases)
|
||||
{
|
||||
RimIdenticalGridCaseGroup* gridCaseGroup = caseGroup();
|
||||
if (gridCaseGroup)
|
||||
{
|
||||
size_t caseCount = gridCaseGroup->caseCollection->reservoirs.size();
|
||||
for (size_t i = 0; i < caseCount; i++)
|
||||
{
|
||||
CVF_ASSERT(gridCaseGroup->caseCollection);
|
||||
CVF_ASSERT(gridCaseGroup->caseCollection->reservoirs[i]);
|
||||
CVF_ASSERT(gridCaseGroup->caseCollection->reservoirs[i]->reservoirData());
|
||||
|
||||
RigEclipseCase* sourceCase = gridCaseGroup->caseCollection->reservoirs[i]->reservoirData();
|
||||
sourceCases.push_back(sourceCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIdenticalGridCaseGroup* RimStatisticalCalculation::caseGroup()
|
||||
{
|
||||
RimStatisticalCollection* statColl = parent();
|
||||
if (statColl)
|
||||
{
|
||||
std::vector<caf::PdmObject*> parentObjects;
|
||||
statColl->parentObjects(parentObjects);
|
||||
|
||||
RimIdenticalGridCaseGroup* gridCaseGroup = NULL;
|
||||
for (size_t i = 0; i < parentObjects.size(); i++)
|
||||
{
|
||||
if (gridCaseGroup) continue;
|
||||
|
||||
caf::PdmObject* obj = parentObjects[i];
|
||||
gridCaseGroup = dynamic_cast<RimIdenticalGridCaseGroup*>(obj);
|
||||
}
|
||||
|
||||
return gridCaseGroup;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ class RimIdenticalGridCaseGroup;
|
||||
class RimResultDefinition;
|
||||
class RifReaderStatisticalCalculation;
|
||||
class RimStatisticalCollection;
|
||||
class RigMainGrid;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
@ -44,8 +45,12 @@ public:
|
||||
RimStatisticalCalculation();
|
||||
virtual ~RimStatisticalCalculation();
|
||||
|
||||
void setMainGrid(RigMainGrid* mainGrid);
|
||||
|
||||
virtual bool openEclipseGridFile();
|
||||
|
||||
caf::PdmField<QString> m_resultName;
|
||||
|
||||
caf::PdmField<bool> statisticsMin;
|
||||
caf::PdmField<bool> statisticsMax;
|
||||
caf::PdmField<bool> statisticsMean;
|
||||
@ -57,11 +62,16 @@ public:
|
||||
void computeStatistics();
|
||||
|
||||
private:
|
||||
RimIdenticalGridCaseGroup* caseGroup();
|
||||
|
||||
void createAndComputeMin();
|
||||
void createAndComputeMax();
|
||||
void createAndComputeMean();
|
||||
void createAndComputeStdDev();
|
||||
|
||||
void getSourceCases(cvf::Collection<RigEclipseCase>& sourceCases);
|
||||
|
||||
|
||||
private:
|
||||
cvf::ref<RifReaderStatisticalCalculation> m_readerInterface;
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "RimReservoirView.h"
|
||||
|
||||
#include "RimStatisticalCollection.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimStatisticalCollection, "RimStatisticalCollection");
|
||||
@ -34,8 +35,6 @@ RimStatisticalCollection::RimStatisticalCollection()
|
||||
CAF_PDM_InitObject("Derived Statistics", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", "");
|
||||
|
||||
createAndAppendStatisticalCalculation();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -52,6 +51,12 @@ RimStatisticalCollection::~RimStatisticalCollection()
|
||||
RimStatisticalCalculation* RimStatisticalCollection::createAndAppendStatisticalCalculation()
|
||||
{
|
||||
RimStatisticalCalculation* newObject = new RimStatisticalCalculation;
|
||||
RimIdenticalGridCaseGroup* gridCaseGroup = parent();
|
||||
|
||||
CVF_ASSERT(gridCaseGroup);
|
||||
CVF_ASSERT(gridCaseGroup->mainGrid());
|
||||
|
||||
newObject->setMainGrid(gridCaseGroup->mainGrid());
|
||||
|
||||
newObject->caseName = "Statistics 1";
|
||||
|
||||
@ -59,3 +64,25 @@ RimStatisticalCalculation* RimStatisticalCollection::createAndAppendStatisticalC
|
||||
|
||||
return newObject;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIdenticalGridCaseGroup* RimStatisticalCollection::parent()
|
||||
{
|
||||
std::vector<caf::PdmObject*> parentObjects;
|
||||
this->parentObjects(parentObjects);
|
||||
|
||||
RimIdenticalGridCaseGroup* gridCaseGroup = NULL;
|
||||
for (size_t i = 0; i < parentObjects.size(); i++)
|
||||
{
|
||||
if (gridCaseGroup) continue;
|
||||
|
||||
caf::PdmObject* obj = parentObjects[i];
|
||||
gridCaseGroup = dynamic_cast<RimIdenticalGridCaseGroup*>(obj);
|
||||
}
|
||||
|
||||
return gridCaseGroup;
|
||||
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,8 @@ public:
|
||||
|
||||
RimStatisticalCalculation* createAndAppendStatisticalCalculation();
|
||||
|
||||
RimIdenticalGridCaseGroup* parent();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user