From 508f33903f2fae6b83366ca8549f3f9c87431a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 20 Jun 2018 10:15:57 +0200 Subject: [PATCH] Delete files that should have been deleted in an earlier commit --- .../ReservoirDataModel/RigCurveDataTools.cpp | 107 --------- .../ReservoirDataModel/RigCurveDataTools.h | 65 ----- .../RigTimeHistoryCurveMerger.cpp | 223 ------------------ .../RigTimeHistoryCurveMerger.h | 69 ------ 4 files changed, 464 deletions(-) delete mode 100644 ApplicationCode/ReservoirDataModel/RigCurveDataTools.cpp delete mode 100644 ApplicationCode/ReservoirDataModel/RigCurveDataTools.h delete mode 100644 ApplicationCode/ReservoirDataModel/RigTimeHistoryCurveMerger.cpp delete mode 100644 ApplicationCode/ReservoirDataModel/RigTimeHistoryCurveMerger.h diff --git a/ApplicationCode/ReservoirDataModel/RigCurveDataTools.cpp b/ApplicationCode/ReservoirDataModel/RigCurveDataTools.cpp deleted file mode 100644 index cb0bcd9cbf..0000000000 --- a/ApplicationCode/ReservoirDataModel/RigCurveDataTools.cpp +++ /dev/null @@ -1,107 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2015- Statoil ASA -// Copyright (C) 2015- 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#include "RigCurveDataTools.h" - - -#include // Needed for HUGE_VAL on Linux - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigCurveDataTools::CurveIntervals RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector& values, - bool includePositiveValuesOnly) -{ - CurveIntervals intervals; - - int startIdx = -1; - size_t vIdx = 0; - - size_t valueCount = values.size(); - while (vIdx < valueCount) - { - bool isValid = RigCurveDataTools::isValidValue(values[vIdx], includePositiveValuesOnly); - - if (!isValid) - { - if (startIdx >= 0) - { - intervals.push_back(std::make_pair(startIdx, vIdx - 1)); - startIdx = -1; - } - } - else if (startIdx < 0) - { - startIdx = (int)vIdx; - } - - vIdx++; - } - - if (startIdx >= 0 && startIdx < ((int)valueCount)) - { - intervals.push_back(std::make_pair(startIdx, valueCount - 1)); - } - - return intervals; -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector> RigCurveDataTools::computePolyLineStartStopIndices(const CurveIntervals& intervals) -{ - std::vector> lineStartAndStopIndices; - - const size_t intervalCount = intervals.size(); - if (intervalCount < 1) return lineStartAndStopIndices; - - size_t index = 0; - for (size_t intIdx = 0; intIdx < intervalCount; intIdx++) - { - size_t intervalSize = intervals[intIdx].second - intervals[intIdx].first + 1; - lineStartAndStopIndices.push_back(std::make_pair(index, index + intervalSize - 1)); - - index += intervalSize; - } - - return lineStartAndStopIndices; -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RigCurveDataTools::isValidValue(double value, bool allowPositiveValuesOnly) -{ - if (value == HUGE_VAL || value == -HUGE_VAL || value != value) - { - return false; - } - - if (allowPositiveValuesOnly && value <= 0) - { - return false; - } - - return true; -} - diff --git a/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h b/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h deleted file mode 100644 index 0e812e5540..0000000000 --- a/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h +++ /dev/null @@ -1,65 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2015- Statoil ASA -// Copyright (C) 2015- 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "cvfAssert.h" - -#include -#include -#include -#include - -class QDateTime; - - -//================================================================================================== -/// -//================================================================================================== -class RigCurveDataTools -{ -public: - typedef std::vector> CurveIntervals; - -public: - static CurveIntervals calculateIntervalsOfValidValues(const std::vector& values, - bool includePositiveValuesOnly); - - template - static void getValuesByIntervals(const std::vector& values, - const CurveIntervals& intervals, - std::vector* filteredValues) - { - CVF_ASSERT(filteredValues); - - for (size_t intIdx = 0; intIdx < intervals.size(); intIdx++) - { - for (size_t vIdx = intervals[intIdx].first; vIdx <= intervals[intIdx].second; vIdx++) - { - filteredValues->push_back(values[vIdx]); - } - } - } - - static std::vector> computePolyLineStartStopIndices(const CurveIntervals& intervals); - -public: - static bool isValidValue(double value, bool allowPositiveValuesOnly); -}; - diff --git a/ApplicationCode/ReservoirDataModel/RigTimeHistoryCurveMerger.cpp b/ApplicationCode/ReservoirDataModel/RigTimeHistoryCurveMerger.cpp deleted file mode 100644 index ec9f45719e..0000000000 --- a/ApplicationCode/ReservoirDataModel/RigTimeHistoryCurveMerger.cpp +++ /dev/null @@ -1,223 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2017 Statoil ASA -// -// 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#include "RigTimeHistoryCurveMerger.h" - - -#include // Needed for HUGE_VAL on Linux - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigTimeHistoryCurveMerger::RigTimeHistoryCurveMerger() -{ - -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigTimeHistoryCurveMerger::addCurveData(const std::vector& values, const std::vector& timeSteps) -{ - CVF_ASSERT(values.size() == timeSteps.size()); - - m_originalValues.push_back(std::make_pair(values, timeSteps)); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigCurveDataTools::CurveIntervals RigTimeHistoryCurveMerger::validIntervalsForAllTimeSteps() const -{ - return m_validIntervalsForAllTimeSteps; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const std::vector& RigTimeHistoryCurveMerger::allTimeSteps() const -{ - return m_allTimeSteps; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const std::vector& RigTimeHistoryCurveMerger::interpolatedCurveValuesForAllTimeSteps(size_t curveIdx) const -{ - CVF_ASSERT(curveIdx < m_interpolatedValuesForAllCurves.size()); - - return m_interpolatedValuesForAllCurves[curveIdx]; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector& RigTimeHistoryCurveMerger::interpolatedCurveValuesForAllTimeSteps(size_t curveIdx) -{ - CVF_ASSERT(curveIdx < m_interpolatedValuesForAllCurves.size()); - - return m_interpolatedValuesForAllCurves[curveIdx]; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -int RigTimeHistoryCurveMerger::interploatedCurveCount() const -{ - return static_cast(m_interpolatedValuesForAllCurves.size()); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigTimeHistoryCurveMerger::computeInterpolatedValues() -{ - m_validIntervalsForAllTimeSteps.clear(); - m_allTimeSteps.clear(); - m_interpolatedValuesForAllCurves.clear(); - - computeUnionOfTimeSteps(); - - const size_t curveCount = m_originalValues.size(); - if (curveCount == 0) - { - return; - } - - const size_t dataValueCount = m_allTimeSteps.size(); - if (dataValueCount == 0) - { - return; - } - - m_interpolatedValuesForAllCurves.resize(curveCount); - - std::vector accumulatedValidValues(dataValueCount, 1.0); - - for (size_t curveIdx = 0; curveIdx < curveCount; curveIdx++) - { - std::vector& curveValues = m_interpolatedValuesForAllCurves[curveIdx]; - curveValues.resize(dataValueCount); - - for (size_t valueIndex = 0; valueIndex < dataValueCount; valueIndex++) - { - double interpolValue = interpolationValue(m_allTimeSteps[valueIndex], m_originalValues[curveIdx].first, m_originalValues[curveIdx].second); - if (!RigCurveDataTools::isValidValue(interpolValue, false)) - { - accumulatedValidValues[valueIndex] = HUGE_VAL; - } - - curveValues[valueIndex] = interpolValue; - } - } - - m_validIntervalsForAllTimeSteps = RigCurveDataTools::calculateIntervalsOfValidValues(accumulatedValidValues, false); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigTimeHistoryCurveMerger::computeUnionOfTimeSteps() -{ - m_allTimeSteps.clear(); - - std::set unionOfTimeSteps; - - for (const auto& curveData : m_originalValues) - { - for (const auto& dt : curveData.second) - { - unionOfTimeSteps.insert(dt); - } - } - - for (const auto& dt : unionOfTimeSteps) - { - m_allTimeSteps.push_back(dt); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double RigTimeHistoryCurveMerger::interpolationValue(const time_t& interpolationTimeStep, - const std::vector& curveValues, - const std::vector& curveTimeSteps) -{ - if (curveValues.size() != curveTimeSteps.size()) return HUGE_VAL; - - const bool removeInterpolatedValues = false; - - for (size_t firstI = 0; firstI < curveTimeSteps.size(); firstI++) - { - if (curveTimeSteps.at(firstI) == interpolationTimeStep) - { - const double& firstValue = curveValues.at(firstI); - if (!RigCurveDataTools::isValidValue(firstValue, removeInterpolatedValues)) - { - return HUGE_VAL; - } - - return firstValue; - } - - size_t secondI = firstI + 1; - - if (secondI < curveTimeSteps.size() && - curveTimeSteps.at(firstI) <= interpolationTimeStep && - curveTimeSteps.at(secondI) > interpolationTimeStep) - { - if (curveTimeSteps.at(secondI) == interpolationTimeStep) - { - const double& secondValue = curveValues.at(secondI); - if (!RigCurveDataTools::isValidValue(secondValue, removeInterpolatedValues)) - { - return HUGE_VAL; - } - - return secondValue; - } - - const double& firstValue = curveValues.at(firstI); - const double& secondValue = curveValues.at(secondI); - - bool isFirstValid = RigCurveDataTools::isValidValue(firstValue, removeInterpolatedValues); - if (!isFirstValid) return HUGE_VAL; - - bool isSecondValid = RigCurveDataTools::isValidValue(secondValue, removeInterpolatedValues); - if (!isSecondValid) return HUGE_VAL; - - double firstDiff = fabs(difftime(interpolationTimeStep, curveTimeSteps.at(firstI))); - double secondDiff = fabs(difftime(curveTimeSteps.at(secondI), interpolationTimeStep)); - - double firstWeight = secondDiff / (firstDiff + secondDiff); - double secondWeight = firstDiff / (firstDiff + secondDiff); - - double val = (firstValue * firstWeight) + (secondValue * secondWeight); - - CVF_ASSERT(RigCurveDataTools::isValidValue(val, removeInterpolatedValues)); - - return val; - } - } - - return HUGE_VAL; -} - diff --git a/ApplicationCode/ReservoirDataModel/RigTimeHistoryCurveMerger.h b/ApplicationCode/ReservoirDataModel/RigTimeHistoryCurveMerger.h deleted file mode 100644 index 325c163a6d..0000000000 --- a/ApplicationCode/ReservoirDataModel/RigTimeHistoryCurveMerger.h +++ /dev/null @@ -1,69 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2017 Statoil ASA -// -// 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "RigCurveDataTools.h" - -#include - - -//================================================================================================== -/// -//================================================================================================== -class RigTimeHistoryCurveMerger -{ -public: - RigTimeHistoryCurveMerger(); - - - void addCurveData(const std::vector& values, - const std::vector& timeSteps); - - void computeInterpolatedValues(); - - RigCurveDataTools::CurveIntervals validIntervalsForAllTimeSteps() const; - const std::vector& allTimeSteps() const; - const std::vector& interpolatedCurveValuesForAllTimeSteps(size_t curveIdx) const; - int interploatedCurveCount() const; - - // Non-const access is not required by any clients, but the expression parser has no available const interface - // for specifying a data source for an expression variable. Allow non-const access to avoid copy of the contained - // values, interpolated for all time steps - // - // See ExpressionParserImpl::assignVector() - std::vector& interpolatedCurveValuesForAllTimeSteps(size_t curveIdx); - -public: - // Helper methods, available as public to be able to access from unit tests - - static double interpolationValue(const time_t& interpolationTimeStep, - const std::vector& curveValues, - const std::vector& curveTimeSteps); - -private: - void computeUnionOfTimeSteps(); - -private: - std::vector, std::vector>> m_originalValues; - - RigCurveDataTools::CurveIntervals m_validIntervalsForAllTimeSteps; - - std::vector m_allTimeSteps; - std::vector> m_interpolatedValuesForAllCurves; -};