2015-05-11 03:56:33 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) Statoil ASA
|
|
|
|
// Copyright (C) Ceetron Solutions 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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "RigStatisticsCalculator.h"
|
2017-03-30 07:56:12 -05:00
|
|
|
|
|
|
|
#include "RigCaseCellResultsData.h"
|
2017-03-30 04:47:38 -05:00
|
|
|
#include "RigActiveCellInfo.h"
|
2015-05-11 03:56:33 -05:00
|
|
|
|
|
|
|
class RigHistogramCalculator;
|
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
///
|
|
|
|
//==================================================================================================
|
2016-12-20 04:39:10 -06:00
|
|
|
|
2015-11-04 08:53:21 -06:00
|
|
|
class RigEclipseNativeStatCalc : public RigStatisticsCalculator
|
2015-05-11 03:56:33 -05:00
|
|
|
{
|
|
|
|
public:
|
2015-11-04 08:53:21 -06:00
|
|
|
RigEclipseNativeStatCalc(RigCaseCellResultsData* cellResultsData, size_t scalarResultIndex);
|
2015-05-11 03:56:33 -05:00
|
|
|
|
2016-12-20 04:39:10 -06:00
|
|
|
virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max);
|
|
|
|
virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg);
|
|
|
|
virtual void valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount);
|
|
|
|
virtual void addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator);
|
2016-07-28 04:41:33 -05:00
|
|
|
virtual void uniqueValues(size_t timeStepIndex, std::set<int>& values);
|
2015-05-11 03:56:33 -05:00
|
|
|
virtual size_t timeStepCount();
|
2017-11-16 08:28:12 -06:00
|
|
|
virtual void mobileVolumeWeightedMean(size_t timeStepIndex, double& mean);
|
2015-05-11 03:56:33 -05:00
|
|
|
|
|
|
|
private:
|
2015-10-23 08:46:25 -05:00
|
|
|
RigCaseCellResultsData* m_resultsData;
|
2016-12-20 04:39:10 -06:00
|
|
|
size_t m_scalarResultIndex;
|
2017-03-30 04:47:38 -05:00
|
|
|
|
|
|
|
template <typename StatisticsAccumulator>
|
|
|
|
void traverseCells(StatisticsAccumulator& accumulator, size_t timeStepIndex)
|
|
|
|
{
|
2018-01-29 03:04:33 -06:00
|
|
|
if (timeStepIndex >= m_resultsData->cellScalarResults(m_scalarResultIndex).size())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-30 04:47:38 -05:00
|
|
|
std::vector<double>& values = m_resultsData->cellScalarResults(m_scalarResultIndex, timeStepIndex);
|
|
|
|
|
|
|
|
if (values.empty())
|
|
|
|
{
|
|
|
|
// Can happen if values do not exist for the current time step index.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo();
|
2017-03-31 04:56:14 -05:00
|
|
|
size_t cellCount = actCellInfo->reservoirCellCount();
|
2017-03-30 04:47:38 -05:00
|
|
|
|
2017-03-31 04:56:14 -05:00
|
|
|
for (size_t cIdx = 0; cIdx < cellCount; ++cIdx)
|
2017-03-30 04:47:38 -05:00
|
|
|
{
|
|
|
|
// Filter out inactive cells
|
|
|
|
if (!actCellInfo->isActive(cIdx)) continue;
|
|
|
|
|
|
|
|
size_t cellResultIndex = cIdx;
|
|
|
|
if (m_resultsData->isUsingGlobalActiveIndex(m_scalarResultIndex))
|
|
|
|
{
|
|
|
|
cellResultIndex = actCellInfo->cellResultIndex(cIdx);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cellResultIndex != cvf::UNDEFINED_SIZE_T && cellResultIndex < values.size())
|
|
|
|
{
|
|
|
|
accumulator.addValue(values[cellResultIndex]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-11 03:56:33 -05:00
|
|
|
};
|