mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Include static properties when computing statistics
p4#: 20870
This commit is contained in:
@@ -150,10 +150,26 @@ void RimStatisticalCalculation::computeStatistics()
|
|||||||
|
|
||||||
RigEclipseCase* resultCase = reservoirData();
|
RigEclipseCase* resultCase = reservoirData();
|
||||||
|
|
||||||
RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase);
|
QList<QPair<RimDefines::ResultCatType, QString> > resultSpecification;
|
||||||
QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::DYNAMIC_NATIVE);
|
|
||||||
|
|
||||||
stat.evaluateStatistics(RimDefines::DYNAMIC_NATIVE, resultNames);
|
{
|
||||||
|
QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::DYNAMIC_NATIVE);
|
||||||
|
foreach(QString resultName, resultNames)
|
||||||
|
{
|
||||||
|
resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, resultName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::STATIC_NATIVE);
|
||||||
|
foreach(QString resultName, resultNames)
|
||||||
|
{
|
||||||
|
resultSpecification.append(qMakePair(RimDefines::STATIC_NATIVE, resultName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase);
|
||||||
|
stat.evaluateStatistics(resultSpecification);
|
||||||
|
|
||||||
for (size_t i = 0; i < reservoirViews().size(); i++)
|
for (size_t i = 0; i < reservoirViews().size(); i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -294,6 +294,8 @@ size_t RigReservoirCellResults::findOrLoadScalarResultForTimeStep(RimDefines::Re
|
|||||||
|
|
||||||
if (type == RimDefines::DYNAMIC_NATIVE && timeStepCount > 0)
|
if (type == RimDefines::DYNAMIC_NATIVE && timeStepCount > 0)
|
||||||
{
|
{
|
||||||
|
m_cellScalarResults[resultGridIndex].resize(timeStepCount);
|
||||||
|
|
||||||
std::vector<double>& values = m_cellScalarResults[resultGridIndex][timeStepIndex];
|
std::vector<double>& values = m_cellScalarResults[resultGridIndex][timeStepIndex];
|
||||||
if (values.size() == 0)
|
if (values.size() == 0)
|
||||||
{
|
{
|
||||||
@@ -305,6 +307,8 @@ size_t RigReservoirCellResults::findOrLoadScalarResultForTimeStep(RimDefines::Re
|
|||||||
}
|
}
|
||||||
else if (type == RimDefines::STATIC_NATIVE)
|
else if (type == RimDefines::STATIC_NATIVE)
|
||||||
{
|
{
|
||||||
|
m_cellScalarResults[resultGridIndex].resize(1);
|
||||||
|
|
||||||
std::vector<double>& values = m_cellScalarResults[resultGridIndex][0];
|
std::vector<double>& values = m_cellScalarResults[resultGridIndex][0];
|
||||||
if (!m_readerInterface->staticResult(resultName, RifReaderInterface::MATRIX_RESULTS, &values))
|
if (!m_readerInterface->staticResult(resultName, RifReaderInterface::MATRIX_RESULTS, &values))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -132,7 +132,31 @@ QString createResultNameDev(const QString& resultName) { return resultName + "_
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, const QStringList& resultNames)
|
void RigStatistics::buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName)
|
||||||
|
{
|
||||||
|
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
|
||||||
|
{
|
||||||
|
RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx);
|
||||||
|
|
||||||
|
RigReservoirCellResults* matrixResults = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS);
|
||||||
|
size_t scalarResultIndex = matrixResults->findOrLoadScalarResult(resultType, resultName);
|
||||||
|
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
|
||||||
|
{
|
||||||
|
QList<QDateTime> timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0);
|
||||||
|
|
||||||
|
size_t scalarResultIndex = matrixResults->addEmptyScalarResult(resultType, resultName);
|
||||||
|
matrixResults->setTimeStepDates(scalarResultIndex, timeStepDates);
|
||||||
|
|
||||||
|
std::vector< std::vector<double> >& dataValues = matrixResults->cellScalarResults(scalarResultIndex);
|
||||||
|
dataValues.resize(timeStepDates.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RigStatistics::evaluateStatistics(const QList<QPair<RimDefines::ResultCatType, QString> >& resultSpecification)
|
||||||
{
|
{
|
||||||
CVF_ASSERT(m_destinationCase.notNull());
|
CVF_ASSERT(m_destinationCase.notNull());
|
||||||
|
|
||||||
@@ -141,8 +165,15 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con
|
|||||||
size_t activeMatrixCellCount = m_destinationCase->activeCellInfo()->globalMatrixModelActiveCellCount();
|
size_t activeMatrixCellCount = m_destinationCase->activeCellInfo()->globalMatrixModelActiveCellCount();
|
||||||
RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS);
|
RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS);
|
||||||
|
|
||||||
foreach(QString resultName, resultNames)
|
for (int i = 0; i < resultSpecification.size(); i++)
|
||||||
{
|
{
|
||||||
|
RimDefines::ResultCatType resultType = resultSpecification[i].first;
|
||||||
|
QString resultName = resultSpecification[i].second;
|
||||||
|
|
||||||
|
// Meta info is loaded from disk for first case only
|
||||||
|
// Build metadata for all other source cases
|
||||||
|
buildSourceMetaData(resultType, resultName);
|
||||||
|
|
||||||
QString minResultName = createResultNameMin(resultName);
|
QString minResultName = createResultNameMin(resultName);
|
||||||
QString maxResultName = createResultNameMax(resultName);
|
QString maxResultName = createResultNameMax(resultName);
|
||||||
QString meanResultName = createResultNameMean(resultName);
|
QString meanResultName = createResultNameMean(resultName);
|
||||||
@@ -170,23 +201,37 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con
|
|||||||
{
|
{
|
||||||
RigGridBase* grid = m_destinationCase->grid(gridIdx);
|
RigGridBase* grid = m_destinationCase->grid(gridIdx);
|
||||||
|
|
||||||
foreach(QString resultName, resultNames)
|
for (int i = 0; i < resultSpecification.size(); i++)
|
||||||
{
|
{
|
||||||
|
RimDefines::ResultCatType resultType = resultSpecification[i].first;
|
||||||
|
QString resultName = resultSpecification[i].second;
|
||||||
|
|
||||||
|
size_t dataAccessTimeStepIndex = timeStepIdx;
|
||||||
|
|
||||||
|
// Always evaluate statistics once, and always use time step index zero
|
||||||
|
if (resultType == RimDefines::STATIC_NATIVE)
|
||||||
|
{
|
||||||
|
if (timeIndicesIdx > 0) continue;
|
||||||
|
|
||||||
|
dataAccessTimeStepIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Build data access objects for source scalar results
|
// Build data access objects for source scalar results
|
||||||
cvf::Collection<cvf::StructGridScalarDataAccess> dataAccesObjectList;
|
cvf::Collection<cvf::StructGridScalarDataAccess> dataAccesObjectList;
|
||||||
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
|
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
|
||||||
{
|
{
|
||||||
RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx);
|
RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx);
|
||||||
|
|
||||||
size_t scalarResultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResultForTimeStep(resultType, resultName, timeStepIdx);
|
size_t scalarResultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResultForTimeStep(resultType, resultName, dataAccessTimeStepIndex);
|
||||||
|
|
||||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = eclipseCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex);
|
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = eclipseCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
|
||||||
if (dataAccessObject.notNull())
|
if (dataAccessObject.notNull())
|
||||||
{
|
{
|
||||||
dataAccesObjectList.push_back(dataAccessObject.p());
|
dataAccesObjectList.push_back(dataAccessObject.p());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Build data access objects form destination scalar results
|
// Build data access objects form destination scalar results
|
||||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectMin = NULL;
|
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectMin = NULL;
|
||||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectMax = NULL;
|
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectMax = NULL;
|
||||||
@@ -194,52 +239,67 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con
|
|||||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectDev = NULL;
|
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectDev = NULL;
|
||||||
|
|
||||||
{
|
{
|
||||||
size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMin(resultName));
|
size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMin(resultName));
|
||||||
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
||||||
{
|
{
|
||||||
dataAccessObjectMin = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex);
|
dataAccessObjectMin = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMax(resultName));
|
size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMax(resultName));
|
||||||
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
||||||
{
|
{
|
||||||
dataAccessObjectMax = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex);
|
dataAccessObjectMax = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMean(resultName));
|
size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMean(resultName));
|
||||||
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
||||||
{
|
{
|
||||||
dataAccessObjectMean = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex);
|
dataAccessObjectMean = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameDev(resultName));
|
size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameDev(resultName));
|
||||||
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
||||||
{
|
{
|
||||||
dataAccessObjectDev = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex);
|
dataAccessObjectDev = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double min, max, mean, dev;
|
double min, max, mean, dev;
|
||||||
std::vector<double> values(dataAccesObjectList.size(), HUGE_VAL);
|
|
||||||
for (size_t cellIdx = 0; cellIdx < grid->cellCount(); cellIdx++)
|
for (size_t cellIdx = 0; cellIdx < grid->cellCount(); cellIdx++)
|
||||||
{
|
{
|
||||||
|
std::vector<double> values(dataAccesObjectList.size(), HUGE_VAL);
|
||||||
|
|
||||||
size_t globalGridCellIdx = grid->globalGridCellIndex(cellIdx);
|
size_t globalGridCellIdx = grid->globalGridCellIndex(cellIdx);
|
||||||
if (m_destinationCase->activeCellInfo()->isActiveInMatrixModel(globalGridCellIdx))
|
if (m_destinationCase->activeCellInfo()->isActiveInMatrixModel(globalGridCellIdx))
|
||||||
{
|
{
|
||||||
|
bool foundAnyValidValues = false;
|
||||||
for (size_t caseIdx = 0; caseIdx < dataAccesObjectList.size(); caseIdx++)
|
for (size_t caseIdx = 0; caseIdx < dataAccesObjectList.size(); caseIdx++)
|
||||||
{
|
{
|
||||||
double val = dataAccesObjectList.at(caseIdx)->cellScalar(cellIdx);
|
double val = dataAccesObjectList.at(caseIdx)->cellScalar(cellIdx);
|
||||||
values[caseIdx] = val;
|
values[caseIdx] = val;
|
||||||
|
|
||||||
|
if (val != HUGE_VAL)
|
||||||
|
{
|
||||||
|
foundAnyValidValues = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RigStatisticsEvaluator stat(values);
|
min = HUGE_VAL;
|
||||||
stat.getStatistics(min, max, mean, dev);
|
max = HUGE_VAL;
|
||||||
|
mean = HUGE_VAL;
|
||||||
|
dev = HUGE_VAL;
|
||||||
|
|
||||||
|
if (foundAnyValidValues)
|
||||||
|
{
|
||||||
|
RigStatisticsEvaluator stat(values);
|
||||||
|
stat.getStatistics(min, max, mean, dev);
|
||||||
|
}
|
||||||
|
|
||||||
if (dataAccessObjectMin.notNull())
|
if (dataAccessObjectMin.notNull())
|
||||||
{
|
{
|
||||||
@@ -289,7 +349,7 @@ void RigStatistics::debugOutput(RimDefines::ResultCatType resultType, const QStr
|
|||||||
qDebug() << resultName << "timeIdx : " << timeStepIdx;
|
qDebug() << resultName << "timeIdx : " << timeStepIdx;
|
||||||
|
|
||||||
RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS);
|
RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS);
|
||||||
size_t scalarResultIndex = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(resultName);
|
size_t scalarResultIndex = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(resultType, resultName);
|
||||||
|
|
||||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = m_destinationCase->dataAccessObject(m_destinationCase->mainGrid(), RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex);
|
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = m_destinationCase->dataAccessObject(m_destinationCase->mainGrid(), RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex);
|
||||||
if (dataAccessObject.isNull()) return;
|
if (dataAccessObject.isNull()) return;
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include <QPair>
|
||||||
|
|
||||||
class RigStatisticsEvaluator
|
class RigStatisticsEvaluator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -34,8 +36,8 @@ public:
|
|||||||
: m_values(values),
|
: m_values(values),
|
||||||
m_min(HUGE_VAL),
|
m_min(HUGE_VAL),
|
||||||
m_max(-HUGE_VAL),
|
m_max(-HUGE_VAL),
|
||||||
m_mean(cvf::UNDEFINED_DOUBLE),
|
m_mean(HUGE_VAL),
|
||||||
m_dev(0.0)
|
m_dev(HUGE_VAL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,13 +130,14 @@ public:
|
|||||||
RigEclipseCase* destinationCase);
|
RigEclipseCase* destinationCase);
|
||||||
|
|
||||||
|
|
||||||
void evaluateStatistics(RimDefines::ResultCatType resultType, const QStringList& resultNames);
|
void evaluateStatistics(const QList<QPair<RimDefines::ResultCatType, QString> >& resultSpecification);
|
||||||
|
|
||||||
void debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx);
|
void debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void computeActiveCellUnion();
|
void computeActiveCellUnion();
|
||||||
void addNamedResult(RigReservoirCellResults* cellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeCellCount);
|
void addNamedResult(RigReservoirCellResults* cellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeCellCount);
|
||||||
|
void buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cvf::Collection<RigEclipseCase> m_sourceCases;
|
cvf::Collection<RigEclipseCase> m_sourceCases;
|
||||||
|
|||||||
Reference in New Issue
Block a user