2013-03-02 08:33:27 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
2013-03-18 08:51:31 -05:00
|
|
|
#include "RIStdInclude.h"
|
2013-03-02 08:33:27 -06:00
|
|
|
|
2013-03-22 08:24:41 -05:00
|
|
|
#include "RimStatisticsCaseEvaluator.h"
|
2013-03-02 08:33:27 -06:00
|
|
|
#include "RigReservoirCellResults.h"
|
2013-03-18 08:34:29 -05:00
|
|
|
#include "RimReservoirView.h"
|
|
|
|
#include "RimReservoir.h"
|
|
|
|
#include "RigEclipseCase.h"
|
2013-03-02 08:33:27 -06:00
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
//#include "RigEclipseCase.h"
|
2013-03-02 08:33:27 -06:00
|
|
|
#include <QDebug>
|
2013-03-05 06:10:26 -06:00
|
|
|
#include "cafProgressInfo.h"
|
2013-03-02 08:33:27 -06:00
|
|
|
|
2013-03-22 07:35:43 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// An internal class to do the actual computations
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
class RimStatisticsEvaluator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RimStatisticsEvaluator(const std::vector<double>& values)
|
|
|
|
: m_values(values),
|
|
|
|
m_min(HUGE_VAL),
|
|
|
|
m_max(-HUGE_VAL),
|
|
|
|
m_mean(HUGE_VAL),
|
|
|
|
m_dev(HUGE_VAL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void getStatistics(double& min, double& max, double& mean, double& dev, double& range)
|
|
|
|
{
|
|
|
|
evaluate();
|
|
|
|
|
|
|
|
min = m_min;
|
|
|
|
max = m_max;
|
|
|
|
mean = m_mean;
|
|
|
|
dev = m_dev;
|
|
|
|
|
|
|
|
range = m_max - m_min;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void evaluate()
|
|
|
|
{
|
|
|
|
double sum = 0.0;
|
|
|
|
double sumSquared = 0.0;
|
|
|
|
|
|
|
|
size_t validValueCount = 0;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < m_values.size(); i++)
|
|
|
|
{
|
|
|
|
double val = m_values[i];
|
|
|
|
if (val == HUGE_VAL) continue;
|
|
|
|
|
|
|
|
validValueCount++;
|
|
|
|
|
|
|
|
if (val < m_min) m_min = val;
|
|
|
|
if (val > m_max) m_max = val;
|
|
|
|
|
|
|
|
sum += val;
|
|
|
|
sumSquared += (val * val);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (validValueCount > 0)
|
|
|
|
{
|
|
|
|
m_mean = sum / validValueCount;
|
|
|
|
|
|
|
|
|
|
|
|
// http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods
|
|
|
|
// Running standard deviation
|
|
|
|
|
|
|
|
double s0 = validValueCount;
|
|
|
|
double s1 = sum;
|
|
|
|
double s2 = sumSquared;
|
|
|
|
|
|
|
|
m_dev = cvf::Math::sqrt( (s0 * s2) - (s1 * s1) ) / s0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
const std::vector<double>& m_values;
|
|
|
|
|
|
|
|
double m_min;
|
|
|
|
double m_max;
|
|
|
|
double m_mean;
|
|
|
|
double m_dev;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-03-02 08:33:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:43:42 -05:00
|
|
|
void RimStatisticsCaseEvaluator::addNamedResult(RigCaseCellResultsData* destinationCellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeUnionCellCount)
|
2013-03-02 08:33:27 -06:00
|
|
|
{
|
2013-03-05 01:34:45 -06:00
|
|
|
// Use time step dates from first result in first source case
|
|
|
|
CVF_ASSERT(m_sourceCases.size() > 0);
|
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
std::vector<QDateTime> sourceTimeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->timeStepDates(0);
|
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
size_t destinationScalarResultIndex = destinationCellResults->addEmptyScalarResult(resultType, resultName, true);
|
2013-03-11 08:04:48 -05:00
|
|
|
CVF_ASSERT(destinationScalarResultIndex != cvf::UNDEFINED_SIZE_T);
|
2013-03-02 08:33:27 -06:00
|
|
|
|
2013-03-11 08:04:48 -05:00
|
|
|
destinationCellResults->setTimeStepDates(destinationScalarResultIndex, sourceTimeStepDates);
|
|
|
|
std::vector< std::vector<double> >& dataValues = destinationCellResults->cellScalarResults(destinationScalarResultIndex);
|
|
|
|
dataValues.resize(sourceTimeStepDates.size());
|
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
|
2013-03-11 08:04:48 -05:00
|
|
|
// Initializes the size of the destination dataset to active union cell count
|
2013-03-20 00:11:45 -05:00
|
|
|
for (size_t i = 0; i < sourceTimeStepDates.size(); i++)
|
2013-03-02 08:33:27 -06:00
|
|
|
{
|
2013-03-11 08:04:48 -05:00
|
|
|
dataValues[i].resize(activeUnionCellCount, HUGE_VAL);
|
2013-03-02 08:33:27 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-08 03:49:33 -06:00
|
|
|
QString createResultNameMin(const QString& resultName) { return resultName + "_MIN"; }
|
|
|
|
QString createResultNameMax(const QString& resultName) { return resultName + "_MAX"; }
|
|
|
|
QString createResultNameMean(const QString& resultName) { return resultName + "_MEAN"; }
|
|
|
|
QString createResultNameDev(const QString& resultName) { return resultName + "_DEV"; }
|
2013-03-22 05:47:46 -05:00
|
|
|
QString createResultNameRange(const QString& resultName) { return resultName + "_RANGE"; }
|
2013-03-08 03:49:33 -06:00
|
|
|
|
|
|
|
|
2013-03-02 08:33:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 04:03:51 -05:00
|
|
|
void RimStatisticsCaseEvaluator::buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName)
|
2013-03-13 01:58:49 -05:00
|
|
|
{
|
2013-03-13 02:03:26 -05:00
|
|
|
if (m_sourceCases.size() == 0) return;
|
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
std::vector<QDateTime> timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->timeStepDates(0);
|
2013-03-13 02:03:26 -05:00
|
|
|
|
|
|
|
for (size_t caseIdx = 1; caseIdx < m_sourceCases.size(); caseIdx++)
|
2013-03-13 01:58:49 -05:00
|
|
|
{
|
2013-03-22 09:43:42 -05:00
|
|
|
RigCaseData* eclipseCase = m_sourceCases.at(caseIdx)->reservoirData();
|
2013-03-13 01:58:49 -05:00
|
|
|
|
2013-03-19 04:29:34 -05:00
|
|
|
RimReservoirCellResultsStorage* matrixResults = m_sourceCases[caseIdx]->results(RifReaderInterface::MATRIX_RESULTS);
|
2013-03-13 01:58:49 -05:00
|
|
|
size_t scalarResultIndex = matrixResults->findOrLoadScalarResult(resultType, resultName);
|
|
|
|
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
|
|
|
|
{
|
2013-03-21 09:31:47 -05:00
|
|
|
size_t scalarResultIndex = matrixResults->cellResults()->addEmptyScalarResult(resultType, resultName, false);
|
2013-03-18 08:34:29 -05:00
|
|
|
matrixResults->cellResults()->setTimeStepDates(scalarResultIndex, timeStepDates);
|
2013-03-13 01:58:49 -05:00
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
std::vector< std::vector<double> >& dataValues = matrixResults->cellResults()->cellScalarResults(scalarResultIndex);
|
2013-03-13 01:58:49 -05:00
|
|
|
dataValues.resize(timeStepDates.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 04:03:51 -05:00
|
|
|
void RimStatisticsCaseEvaluator::evaluateForResults(const QList<QPair<RimDefines::ResultCatType, QString> >& resultSpecification)
|
2013-03-02 08:33:27 -06:00
|
|
|
{
|
2013-03-13 08:43:27 -05:00
|
|
|
CVF_ASSERT(m_destinationCase);
|
2013-03-02 08:33:27 -06:00
|
|
|
|
2013-03-22 03:32:42 -05:00
|
|
|
size_t activeMatrixCellCount = m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalActiveCellCount();
|
2013-03-22 09:43:42 -05:00
|
|
|
RigCaseCellResultsData* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS);
|
2013-03-05 06:10:26 -06:00
|
|
|
|
2013-03-13 01:58:49 -05:00
|
|
|
for (int i = 0; i < resultSpecification.size(); i++)
|
2013-03-08 03:49:33 -06:00
|
|
|
{
|
2013-03-13 01:58:49 -05:00
|
|
|
RimDefines::ResultCatType resultType = resultSpecification[i].first;
|
|
|
|
QString resultName = resultSpecification[i].second;
|
|
|
|
|
2013-03-13 04:29:47 -05:00
|
|
|
// Special handling if SOIL is asked for
|
|
|
|
// Build SGAS/SWAT meta data, SOIL is automatically generated as part of RigReservoirCellResults::findOrLoadScalarResultForTimeStep
|
|
|
|
if (resultName.toUpper() == "SOIL")
|
|
|
|
{
|
2013-03-18 08:34:29 -05:00
|
|
|
size_t swatIndex = m_sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->findScalarResultIndex(resultType, "SWAT");
|
2013-03-13 04:29:47 -05:00
|
|
|
if (swatIndex != cvf::UNDEFINED_SIZE_T)
|
|
|
|
{
|
|
|
|
buildSourceMetaData(resultType, "SWAT");
|
|
|
|
}
|
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
size_t sgasIndex = m_sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->findScalarResultIndex(resultType, "SGAS");
|
2013-03-13 04:29:47 -05:00
|
|
|
if (sgasIndex != cvf::UNDEFINED_SIZE_T)
|
|
|
|
{
|
|
|
|
buildSourceMetaData(resultType, "SGAS");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-13 05:50:31 -05:00
|
|
|
// Meta info is loaded from disk for first case only
|
|
|
|
// Build metadata for all other source cases
|
|
|
|
buildSourceMetaData(resultType, resultName);
|
2013-03-13 04:29:47 -05:00
|
|
|
}
|
2013-03-13 01:58:49 -05:00
|
|
|
|
2013-03-08 03:49:33 -06:00
|
|
|
QString minResultName = createResultNameMin(resultName);
|
|
|
|
QString maxResultName = createResultNameMax(resultName);
|
|
|
|
QString meanResultName = createResultNameMean(resultName);
|
|
|
|
QString devResultName = createResultNameDev(resultName);
|
2013-03-22 05:47:46 -05:00
|
|
|
QString rangeResultName = createResultNameRange(resultName);
|
2013-03-02 08:33:27 -06:00
|
|
|
|
2013-03-11 08:04:48 -05:00
|
|
|
if (activeMatrixCellCount > 0)
|
|
|
|
{
|
|
|
|
addNamedResult(matrixResults, resultType, minResultName, activeMatrixCellCount);
|
|
|
|
addNamedResult(matrixResults, resultType, maxResultName, activeMatrixCellCount);
|
|
|
|
addNamedResult(matrixResults, resultType, meanResultName, activeMatrixCellCount);
|
|
|
|
addNamedResult(matrixResults, resultType, devResultName, activeMatrixCellCount);
|
2013-03-22 05:47:46 -05:00
|
|
|
addNamedResult(matrixResults, resultType, rangeResultName, activeMatrixCellCount);
|
2013-03-11 08:04:48 -05:00
|
|
|
}
|
2013-03-08 03:49:33 -06:00
|
|
|
}
|
2013-03-02 08:33:27 -06:00
|
|
|
|
|
|
|
if (activeMatrixCellCount > 0)
|
|
|
|
{
|
2013-03-05 06:10:26 -06:00
|
|
|
caf::ProgressInfo info(m_timeStepIndices.size(), "Computing Statistics");
|
|
|
|
|
2013-03-02 08:33:27 -06:00
|
|
|
for (size_t timeIndicesIdx = 0; timeIndicesIdx < m_timeStepIndices.size(); timeIndicesIdx++)
|
|
|
|
{
|
|
|
|
size_t timeStepIdx = m_timeStepIndices[timeIndicesIdx];
|
|
|
|
|
|
|
|
size_t gridCount = 0;
|
|
|
|
for (size_t gridIdx = 0; gridIdx < m_destinationCase->gridCount(); gridIdx++)
|
|
|
|
{
|
|
|
|
RigGridBase* grid = m_destinationCase->grid(gridIdx);
|
|
|
|
|
2013-03-13 01:58:49 -05:00
|
|
|
for (int i = 0; i < resultSpecification.size(); i++)
|
2013-03-08 03:49:33 -06:00
|
|
|
{
|
2013-03-13 01:58:49 -05:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-03-11 08:04:48 -05:00
|
|
|
// Build data access objects for source scalar results
|
|
|
|
cvf::Collection<cvf::StructGridScalarDataAccess> dataAccesObjectList;
|
|
|
|
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
|
2013-03-02 08:33:27 -06:00
|
|
|
{
|
2013-03-22 09:43:42 -05:00
|
|
|
RimCase* eclipseCase = m_sourceCases.at(caseIdx);
|
2013-03-02 08:33:27 -06:00
|
|
|
|
2013-03-13 01:58:49 -05:00
|
|
|
size_t scalarResultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResultForTimeStep(resultType, resultName, dataAccessTimeStepIndex);
|
2013-03-02 08:33:27 -06:00
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = eclipseCase->reservoirData()->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
|
2013-03-11 08:04:48 -05:00
|
|
|
if (dataAccessObject.notNull())
|
|
|
|
{
|
|
|
|
dataAccesObjectList.push_back(dataAccessObject.p());
|
|
|
|
}
|
2013-03-02 08:33:27 -06:00
|
|
|
}
|
|
|
|
|
2013-03-13 01:58:49 -05:00
|
|
|
|
2013-03-11 08:04:48 -05:00
|
|
|
// Build data access objects form destination scalar results
|
|
|
|
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectMin = NULL;
|
|
|
|
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectMax = NULL;
|
|
|
|
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectMean = NULL;
|
|
|
|
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectDev = NULL;
|
2013-03-22 05:47:46 -05:00
|
|
|
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectRange = NULL;
|
2013-03-02 08:33:27 -06:00
|
|
|
|
|
|
|
{
|
2013-03-13 01:58:49 -05:00
|
|
|
size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMin(resultName));
|
2013-03-11 08:04:48 -05:00
|
|
|
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
2013-03-02 08:33:27 -06:00
|
|
|
{
|
2013-03-13 01:58:49 -05:00
|
|
|
dataAccessObjectMin = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
|
2013-03-02 08:33:27 -06:00
|
|
|
}
|
2013-03-11 08:04:48 -05:00
|
|
|
}
|
2013-03-02 08:33:27 -06:00
|
|
|
|
2013-03-11 08:04:48 -05:00
|
|
|
{
|
2013-03-13 01:58:49 -05:00
|
|
|
size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMax(resultName));
|
2013-03-11 08:04:48 -05:00
|
|
|
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
2013-03-02 08:33:27 -06:00
|
|
|
{
|
2013-03-13 01:58:49 -05:00
|
|
|
dataAccessObjectMax = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
|
2013-03-02 08:33:27 -06:00
|
|
|
}
|
2013-03-11 08:04:48 -05:00
|
|
|
}
|
2013-03-02 08:33:27 -06:00
|
|
|
|
2013-03-11 08:04:48 -05:00
|
|
|
{
|
2013-03-13 01:58:49 -05:00
|
|
|
size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMean(resultName));
|
2013-03-11 08:04:48 -05:00
|
|
|
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
2013-03-02 08:33:27 -06:00
|
|
|
{
|
2013-03-13 01:58:49 -05:00
|
|
|
dataAccessObjectMean = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
|
2013-03-02 08:33:27 -06:00
|
|
|
}
|
2013-03-11 08:04:48 -05:00
|
|
|
}
|
2013-03-02 08:33:27 -06:00
|
|
|
|
2013-03-11 08:04:48 -05:00
|
|
|
{
|
2013-03-13 01:58:49 -05:00
|
|
|
size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameDev(resultName));
|
2013-03-11 08:04:48 -05:00
|
|
|
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
2013-03-02 08:33:27 -06:00
|
|
|
{
|
2013-03-13 01:58:49 -05:00
|
|
|
dataAccessObjectDev = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
|
2013-03-02 08:33:27 -06:00
|
|
|
}
|
2013-03-11 08:04:48 -05:00
|
|
|
}
|
2013-03-02 08:33:27 -06:00
|
|
|
|
2013-03-22 05:47:46 -05:00
|
|
|
{
|
|
|
|
size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameRange(resultName));
|
|
|
|
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
|
|
|
{
|
|
|
|
dataAccessObjectRange = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double min, max, mean, dev, range;
|
2013-03-11 08:04:48 -05:00
|
|
|
for (size_t cellIdx = 0; cellIdx < grid->cellCount(); cellIdx++)
|
|
|
|
{
|
2013-03-13 01:58:49 -05:00
|
|
|
std::vector<double> values(dataAccesObjectList.size(), HUGE_VAL);
|
|
|
|
|
2013-03-11 08:04:48 -05:00
|
|
|
size_t globalGridCellIdx = grid->globalGridCellIndex(cellIdx);
|
2013-03-22 05:47:46 -05:00
|
|
|
if (m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActive(globalGridCellIdx))
|
2013-03-02 08:33:27 -06:00
|
|
|
{
|
2013-03-13 01:58:49 -05:00
|
|
|
bool foundAnyValidValues = false;
|
2013-03-11 08:04:48 -05:00
|
|
|
for (size_t caseIdx = 0; caseIdx < dataAccesObjectList.size(); caseIdx++)
|
|
|
|
{
|
|
|
|
double val = dataAccesObjectList.at(caseIdx)->cellScalar(cellIdx);
|
|
|
|
values[caseIdx] = val;
|
2013-03-13 01:58:49 -05:00
|
|
|
|
|
|
|
if (val != HUGE_VAL)
|
|
|
|
{
|
|
|
|
foundAnyValidValues = true;
|
|
|
|
}
|
2013-03-11 08:04:48 -05:00
|
|
|
}
|
|
|
|
|
2013-03-13 01:58:49 -05:00
|
|
|
min = HUGE_VAL;
|
|
|
|
max = HUGE_VAL;
|
|
|
|
mean = HUGE_VAL;
|
|
|
|
dev = HUGE_VAL;
|
2013-03-22 05:47:46 -05:00
|
|
|
range = HUGE_VAL;
|
2013-03-13 01:58:49 -05:00
|
|
|
|
|
|
|
if (foundAnyValidValues)
|
|
|
|
{
|
2013-03-22 04:03:51 -05:00
|
|
|
RimStatisticsEvaluator stat(values);
|
2013-03-22 05:47:46 -05:00
|
|
|
stat.getStatistics(min, max, mean, dev, range);
|
2013-03-13 01:58:49 -05:00
|
|
|
}
|
2013-03-11 08:04:48 -05:00
|
|
|
|
|
|
|
if (dataAccessObjectMin.notNull())
|
|
|
|
{
|
|
|
|
dataAccessObjectMin->setCellScalar(cellIdx, min);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dataAccessObjectMax.notNull())
|
|
|
|
{
|
|
|
|
dataAccessObjectMax->setCellScalar(cellIdx, max);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dataAccessObjectMean.notNull())
|
|
|
|
{
|
|
|
|
dataAccessObjectMean->setCellScalar(cellIdx, mean);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dataAccessObjectDev.notNull())
|
|
|
|
{
|
|
|
|
dataAccessObjectDev->setCellScalar(cellIdx, dev);
|
|
|
|
}
|
2013-03-22 05:47:46 -05:00
|
|
|
|
|
|
|
if (dataAccessObjectRange.notNull())
|
|
|
|
{
|
|
|
|
dataAccessObjectRange->setCellScalar(cellIdx, range);
|
|
|
|
}
|
2013-03-02 08:33:27 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-05 06:10:26 -06:00
|
|
|
|
|
|
|
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
|
|
|
|
{
|
2013-03-22 09:43:42 -05:00
|
|
|
RimCase* eclipseCase = m_sourceCases.at(caseIdx);
|
2013-03-05 06:10:26 -06:00
|
|
|
|
|
|
|
// When one time step is completed, close all result files.
|
|
|
|
// Microsoft note: On Windows, the maximum number of files open at the same time is 512
|
|
|
|
// http://msdn.microsoft.com/en-us/library/kdfaxaay%28vs.71%29.aspx
|
|
|
|
//
|
2013-03-18 08:34:29 -05:00
|
|
|
eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->readerInterface()->close();
|
2013-03-05 06:10:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
info.setProgress(timeIndicesIdx);
|
2013-03-02 08:33:27 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 04:03:51 -05:00
|
|
|
void RimStatisticsCaseEvaluator::debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx)
|
2013-03-02 08:33:27 -06:00
|
|
|
{
|
2013-03-13 08:43:27 -05:00
|
|
|
CVF_ASSERT(m_destinationCase);
|
|
|
|
|
2013-03-02 08:33:27 -06:00
|
|
|
qDebug() << resultName << "timeIdx : " << timeStepIdx;
|
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
size_t scalarResultIndex = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultType, resultName);
|
2013-03-02 08:33:27 -06:00
|
|
|
|
|
|
|
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = m_destinationCase->dataAccessObject(m_destinationCase->mainGrid(), RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex);
|
|
|
|
if (dataAccessObject.isNull()) return;
|
|
|
|
|
|
|
|
for (size_t cellIdx = 0; cellIdx < m_globalCellCount; cellIdx++)
|
|
|
|
{
|
|
|
|
qDebug() << dataAccessObject->cellScalar(cellIdx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:43:42 -05:00
|
|
|
RimStatisticsCaseEvaluator::RimStatisticsCaseEvaluator(const std::vector<RimCase*>& sourceCases, const std::vector<size_t>& timeStepIndices, const RimStatisticsConfig& statisticsConfig, RigCaseData* destinationCase)
|
2013-03-18 08:34:29 -05:00
|
|
|
: m_sourceCases(sourceCases),
|
2013-03-02 08:33:27 -06:00
|
|
|
m_statisticsConfig(statisticsConfig),
|
|
|
|
m_destinationCase(destinationCase),
|
|
|
|
m_globalCellCount(0),
|
|
|
|
m_timeStepIndices(timeStepIndices)
|
|
|
|
{
|
|
|
|
if (sourceCases.size() > 0)
|
|
|
|
{
|
2013-03-18 08:34:29 -05:00
|
|
|
m_globalCellCount = sourceCases[0]->reservoirData()->mainGrid()->cells().size();
|
2013-03-02 08:33:27 -06:00
|
|
|
}
|
2013-03-13 08:43:27 -05:00
|
|
|
|
|
|
|
CVF_ASSERT(m_destinationCase);
|
2013-03-02 08:33:27 -06:00
|
|
|
}
|
2013-03-05 06:10:26 -06:00
|
|
|
|