mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Split classes in RigStatisticsCalculator.h/.cpp into separate files
New files:RigNativeStatCalc.h./cpp, RigMultipleDatasetStatCalc.h/.cpp., in addition to RigStatisticsCalculator.h/.cpp.
This commit is contained in:
parent
da7035517f
commit
ca17645499
@ -35,6 +35,8 @@ ${CEE_CURRENT_LIST_DIR}RigResultAccessor2d.h
|
||||
${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h
|
||||
${CEE_CURRENT_LIST_DIR}RigStatisticsDataCache.h
|
||||
${CEE_CURRENT_LIST_DIR}RigStatisticsCalculator.h
|
||||
${CEE_CURRENT_LIST_DIR}RigNativeStatCalc.h
|
||||
${CEE_CURRENT_LIST_DIR}RigMultipleDatasetStatCalc.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -64,6 +66,8 @@ ${CEE_CURRENT_LIST_DIR}cvfGeometryTools.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigStatisticsDataCache.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigStatisticsCalculator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigNativeStatCalc.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigMultipleDatasetStatCalc.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -23,7 +23,8 @@
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigStatisticsDataCache.h"
|
||||
#include "RigStatisticsMath.h"
|
||||
#include "RigStatisticsCalculator.h"
|
||||
#include "RigMultipleDatasetStatCalc.h"
|
||||
#include "RigNativeStatCalc.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <math.h>
|
||||
|
@ -0,0 +1,121 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RigMultipleDatasetStatCalc.h"
|
||||
#include "RigNativeStatCalc.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigMultipleDatasetStatCalc::RigMultipleDatasetStatCalc()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigMultipleDatasetStatCalc::addStatisticsCalculator(RigStatisticsCalculator* statisticsCalculator)
|
||||
{
|
||||
if (statisticsCalculator)
|
||||
{
|
||||
m_nativeStatisticsCalculators.push_back(statisticsCalculator);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigMultipleDatasetStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max)
|
||||
{
|
||||
for (size_t i = 0; i < m_nativeStatisticsCalculators.size(); i++)
|
||||
{
|
||||
if (m_nativeStatisticsCalculators.at(i))
|
||||
{
|
||||
m_nativeStatisticsCalculators.at(i)->minMaxCellScalarValues(timeStepIndex, min, max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigMultipleDatasetStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg)
|
||||
{
|
||||
for (size_t i = 0; i < m_nativeStatisticsCalculators.size(); i++)
|
||||
{
|
||||
if (m_nativeStatisticsCalculators.at(i))
|
||||
{
|
||||
m_nativeStatisticsCalculators.at(i)->posNegClosestToZero(timeStepIndex, pos, neg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigMultipleDatasetStatCalc::valueSumAndSampleCount(double& valueSum, size_t& sampleCount)
|
||||
{
|
||||
for (size_t i = 0; i < m_nativeStatisticsCalculators.size(); i++)
|
||||
{
|
||||
if (m_nativeStatisticsCalculators.at(i))
|
||||
{
|
||||
m_nativeStatisticsCalculators.at(i)->valueSumAndSampleCount(valueSum, sampleCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigMultipleDatasetStatCalc::addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator)
|
||||
{
|
||||
for (size_t i = 0; i < m_nativeStatisticsCalculators.size(); i++)
|
||||
{
|
||||
if (m_nativeStatisticsCalculators.at(i))
|
||||
{
|
||||
m_nativeStatisticsCalculators.at(i)->addDataToHistogramCalculator(histogramCalculator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RigMultipleDatasetStatCalc::timeStepCount()
|
||||
{
|
||||
if (m_nativeStatisticsCalculators.size() > 0)
|
||||
{
|
||||
return m_nativeStatisticsCalculators[0]->timeStepCount();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigMultipleDatasetStatCalc::addNativeStatisticsCalculator(RigCaseCellResultsData* cellResultsData, size_t scalarResultIndex)
|
||||
{
|
||||
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
this->addStatisticsCalculator(new RigNativeStatCalc(cellResultsData, scalarResultIndex));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfCollection.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RigHistogramCalculator;
|
||||
class RigCaseCellResultsData;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RigMultipleDatasetStatCalc : public RigStatisticsCalculator
|
||||
{
|
||||
public:
|
||||
RigMultipleDatasetStatCalc();
|
||||
void addStatisticsCalculator(RigStatisticsCalculator* statisticsCalculator);
|
||||
void addNativeStatisticsCalculator(RigCaseCellResultsData* cellResultsData, size_t scalarResultIndices);
|
||||
|
||||
virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max);
|
||||
virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg);
|
||||
|
||||
virtual void valueSumAndSampleCount(double& valueSum, size_t& sampleCount);
|
||||
virtual void addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator);
|
||||
|
||||
virtual size_t timeStepCount();
|
||||
|
||||
private:
|
||||
std::vector<RigStatisticsCalculator*> m_nativeStatisticsCalculators;
|
||||
};
|
139
ApplicationCode/ReservoirDataModel/RigNativeStatCalc.cpp
Normal file
139
ApplicationCode/ReservoirDataModel/RigNativeStatCalc.cpp
Normal file
@ -0,0 +1,139 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RigNativeStatCalc.h"
|
||||
|
||||
#include "RigStatisticsMath.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigStatisticsMath.h"
|
||||
|
||||
#include <cmath> // Needed for HUGE_VAL on Linux
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigNativeStatCalc::RigNativeStatCalc(RigCaseCellResultsData* cellResultsData, size_t scalarResultIndex)
|
||||
: m_resultsData(cellResultsData),
|
||||
m_scalarResultIndex(scalarResultIndex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigNativeStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max)
|
||||
{
|
||||
std::vector<double>& values = m_resultsData->cellScalarResults(m_scalarResultIndex, timeStepIndex);
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < values.size(); i++)
|
||||
{
|
||||
if (values[i] == HUGE_VAL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (values[i] < min)
|
||||
{
|
||||
min = values[i];
|
||||
}
|
||||
|
||||
if (values[i] > max)
|
||||
{
|
||||
max = values[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigNativeStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg)
|
||||
{
|
||||
std::vector<double>& values = m_resultsData->cellScalarResults(m_scalarResultIndex, timeStepIndex);
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < values.size(); i++)
|
||||
{
|
||||
if (values[i] == HUGE_VAL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (values[i] < pos && values[i] > 0)
|
||||
{
|
||||
pos = values[i];
|
||||
}
|
||||
|
||||
if (values[i] > neg && values[i] < 0)
|
||||
{
|
||||
neg = values[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigNativeStatCalc::addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator)
|
||||
{
|
||||
for (size_t tIdx = 0; tIdx < m_resultsData->timeStepCount(m_scalarResultIndex); tIdx++)
|
||||
{
|
||||
std::vector<double>& values = m_resultsData->cellScalarResults(m_scalarResultIndex, tIdx);
|
||||
|
||||
histogramCalculator.addData(values);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigNativeStatCalc::valueSumAndSampleCount(double& valueSum, size_t& sampleCount)
|
||||
{
|
||||
for (size_t tIdx = 0; tIdx < m_resultsData->timeStepCount(m_scalarResultIndex); tIdx++)
|
||||
{
|
||||
std::vector<double>& values = m_resultsData->cellScalarResults(m_scalarResultIndex, tIdx);
|
||||
size_t undefValueCount = 0;
|
||||
for (size_t cIdx = 0; cIdx < values.size(); ++cIdx)
|
||||
{
|
||||
double value = values[cIdx];
|
||||
if (value == HUGE_VAL || value != value)
|
||||
{
|
||||
++undefValueCount;
|
||||
continue;
|
||||
}
|
||||
|
||||
valueSum += value;
|
||||
}
|
||||
|
||||
sampleCount += values.size();
|
||||
sampleCount -= undefValueCount;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RigNativeStatCalc::timeStepCount()
|
||||
{
|
||||
return m_resultsData->timeStepCount(m_scalarResultIndex);
|
||||
}
|
49
ApplicationCode/ReservoirDataModel/RigNativeStatCalc.h
Normal file
49
ApplicationCode/ReservoirDataModel/RigNativeStatCalc.h
Normal file
@ -0,0 +1,49 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfCollection.h"
|
||||
|
||||
class RigHistogramCalculator;
|
||||
class RigCaseCellResultsData;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RigNativeStatCalc : public RigStatisticsCalculator
|
||||
{
|
||||
public:
|
||||
RigNativeStatCalc(RigCaseCellResultsData* cellResultsData, size_t scalarResultIndex);
|
||||
|
||||
virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max);
|
||||
virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg);
|
||||
virtual void valueSumAndSampleCount(double& valueSum, size_t& sampleCount);
|
||||
|
||||
virtual void addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator);
|
||||
virtual size_t timeStepCount();
|
||||
|
||||
private:
|
||||
RigCaseCellResultsData* m_resultsData;
|
||||
size_t m_scalarResultIndex;
|
||||
};
|
@ -26,7 +26,6 @@
|
||||
#include <vector>
|
||||
|
||||
class RigHistogramCalculator;
|
||||
class RigCaseCellResultsData;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -43,47 +42,3 @@ public:
|
||||
|
||||
virtual size_t timeStepCount() = 0;
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RigNativeStatCalc : public RigStatisticsCalculator
|
||||
{
|
||||
public:
|
||||
RigNativeStatCalc(RigCaseCellResultsData* cellResultsData, size_t scalarResultIndex);
|
||||
|
||||
virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max);
|
||||
virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg);
|
||||
virtual void valueSumAndSampleCount(double& valueSum, size_t& sampleCount);
|
||||
|
||||
virtual void addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator);
|
||||
virtual size_t timeStepCount();
|
||||
|
||||
private:
|
||||
RigCaseCellResultsData* m_resultsData;
|
||||
size_t m_scalarResultIndex;
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RigMultipleDatasetStatCalc : public RigStatisticsCalculator
|
||||
{
|
||||
public:
|
||||
RigMultipleDatasetStatCalc();
|
||||
void addStatisticsCalculator(RigStatisticsCalculator* statisticsCalculator);
|
||||
void addNativeStatisticsCalculator(RigCaseCellResultsData* cellResultsData, size_t scalarResultIndices);
|
||||
|
||||
virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max);
|
||||
virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg);
|
||||
|
||||
virtual void valueSumAndSampleCount(double& valueSum, size_t& sampleCount);
|
||||
virtual void addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator);
|
||||
|
||||
virtual size_t timeStepCount();
|
||||
|
||||
private:
|
||||
std::vector<RigStatisticsCalculator*> m_nativeStatisticsCalculators;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user