mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-01 03:37:15 -06:00
Moved code to new library: ResultStatisticsCache
Moved RigStatisticsCalculator.h/.cpp, RigStatisticsDataCache.h/.cpp, RigStatisticsMath.h/.cpp to new library ResultStatisticsCache. ResInsight and some unit tests now link with this new library.
This commit is contained in:
parent
ca17645499
commit
85f62ec1d4
@ -18,6 +18,7 @@ include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ModelVisualization
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ResultStatisticsCache
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ReservoirDataModel
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/WellPathImportSsihub
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/OdbReader
|
||||
@ -100,6 +101,7 @@ list( APPEND CPP_SOURCES
|
||||
#############################################################################
|
||||
|
||||
add_subdirectory(WellPathImportSsihub)
|
||||
add_subdirectory(ResultStatisticsCache)
|
||||
|
||||
#
|
||||
# Odb api
|
||||
@ -292,6 +294,7 @@ set( LINK_LIBRARIES
|
||||
LibGeometry
|
||||
LibCore
|
||||
|
||||
ResultStatisticsCache
|
||||
RigGeoMechDataModel
|
||||
|
||||
ecl
|
||||
|
@ -10,7 +10,8 @@ include (${QT_USE_FILE})
|
||||
|
||||
include_directories(
|
||||
${ResInsight_SOURCE_DIR}/ApplicationCode
|
||||
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel
|
||||
${ResInsight_SOURCE_DIR}/ApplicationCode/ResultStatisticsCache
|
||||
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel
|
||||
${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface
|
||||
${ResInsight_SOURCE_DIR}/ApplicationCode/ProjectDataModel
|
||||
${ResInsight_SOURCE_DIR}/ThirdParty
|
||||
@ -63,6 +64,8 @@ set( LINK_LIBRARIES
|
||||
cafProjectDataModel
|
||||
CommonCode
|
||||
|
||||
ResultStatisticsCache
|
||||
|
||||
LibViewing
|
||||
LibRender
|
||||
LibGeometry
|
||||
|
@ -24,7 +24,6 @@ ${CEE_CURRENT_LIST_DIR}RigMainGrid.h
|
||||
${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.h
|
||||
${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.h
|
||||
${CEE_CURRENT_LIST_DIR}RigSingleWellResultsData.h
|
||||
${CEE_CURRENT_LIST_DIR}RigStatisticsMath.h
|
||||
${CEE_CURRENT_LIST_DIR}RigWellPath.h
|
||||
${CEE_CURRENT_LIST_DIR}RigFault.h
|
||||
${CEE_CURRENT_LIST_DIR}RigNNCData.h
|
||||
@ -33,8 +32,6 @@ ${CEE_CURRENT_LIST_DIR}cvfGeometryTools.inl
|
||||
${CEE_CURRENT_LIST_DIR}RigPipeInCellEvaluator.h
|
||||
${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
|
||||
)
|
||||
@ -58,14 +55,11 @@ ${CEE_CURRENT_LIST_DIR}RigMainGrid.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigSingleWellResultsData.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigStatisticsMath.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigWellPath.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigFault.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigNNCData.cpp
|
||||
${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
|
||||
)
|
||||
|
@ -14,6 +14,7 @@ include_directories(
|
||||
${LibViewing_SOURCE_DIR}
|
||||
|
||||
${ResInsight_SOURCE_DIR}/ApplicationCode
|
||||
${ResInsight_SOURCE_DIR}/ApplicationCode/ResultStatisticsCache
|
||||
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel
|
||||
${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface
|
||||
${ResInsight_SOURCE_DIR}/ApplicationCode/ProjectDataModel
|
||||
@ -53,6 +54,8 @@ source_group( "UnitTests" FILES ${UNIT_TEST_CPP_SOURCES} )
|
||||
set( LINK_LIBRARIES
|
||||
CommonCode
|
||||
|
||||
ResultStatisticsCache
|
||||
|
||||
LibViewing
|
||||
LibRender
|
||||
LibGeometry
|
||||
|
@ -1,262 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RigStatisticsCalculator.h"
|
||||
|
||||
#include "RigStatisticsMath.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
|
||||
#include <cmath> // Needed for HUGE_VAL on Linux
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigStatisticsCalculator::meanCellScalarValue(double& meanValue)
|
||||
{
|
||||
double valueSum = 0.0;
|
||||
size_t sampleCount = 0;
|
||||
|
||||
this->valueSumAndSampleCount(valueSum, sampleCount);
|
||||
|
||||
if (sampleCount == 0)
|
||||
{
|
||||
meanValue = HUGE_VAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
meanValue = valueSum / sampleCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
18
ApplicationCode/ResultStatisticsCache/CMakeLists.txt
Normal file
18
ApplicationCode/ResultStatisticsCache/CMakeLists.txt
Normal file
@ -0,0 +1,18 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
project (ResultStatisticsCache)
|
||||
|
||||
include_directories(
|
||||
${LibCore_SOURCE_DIR}
|
||||
)
|
||||
|
||||
add_library( ${PROJECT_NAME}
|
||||
RigStatisticsCalculator.h
|
||||
RigStatisticsCalculator.cpp
|
||||
RigStatisticsDataCache.h
|
||||
RigStatisticsDataCache.cpp
|
||||
RigStatisticsMath.h
|
||||
RigStatisticsMath.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} LibCore)
|
@ -0,0 +1,44 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RigStatisticsCalculator.h"
|
||||
|
||||
#include <cmath> // Needed for HUGE_VAL on Linux
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigStatisticsCalculator::meanCellScalarValue(double& meanValue)
|
||||
{
|
||||
double valueSum = 0.0;
|
||||
size_t sampleCount = 0;
|
||||
|
||||
this->valueSumAndSampleCount(valueSum, sampleCount);
|
||||
|
||||
if (sampleCount == 0)
|
||||
{
|
||||
meanValue = HUGE_VAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
meanValue = valueSum / sampleCount;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user