mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Delete files that should have been deleted in an earlier commit
This commit is contained in:
parent
b0a6b81363
commit
508f33903f
@ -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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RigCurveDataTools.h"
|
||||
|
||||
|
||||
#include <cmath> // Needed for HUGE_VAL on Linux
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigCurveDataTools::CurveIntervals RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double>& 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<std::pair<size_t, size_t>> RigCurveDataTools::computePolyLineStartStopIndices(const CurveIntervals& intervals)
|
||||
{
|
||||
std::vector<std::pair<size_t, size_t>> 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;
|
||||
}
|
||||
|
@ -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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <set>
|
||||
|
||||
class QDateTime;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RigCurveDataTools
|
||||
{
|
||||
public:
|
||||
typedef std::vector<std::pair<size_t, size_t>> CurveIntervals;
|
||||
|
||||
public:
|
||||
static CurveIntervals calculateIntervalsOfValidValues(const std::vector<double>& values,
|
||||
bool includePositiveValuesOnly);
|
||||
|
||||
template <typename T>
|
||||
static void getValuesByIntervals(const std::vector<T>& values,
|
||||
const CurveIntervals& intervals,
|
||||
std::vector<T>* 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<std::pair<size_t, size_t>> computePolyLineStartStopIndices(const CurveIntervals& intervals);
|
||||
|
||||
public:
|
||||
static bool isValidValue(double value, bool allowPositiveValuesOnly);
|
||||
};
|
||||
|
@ -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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RigTimeHistoryCurveMerger.h"
|
||||
|
||||
|
||||
#include <cmath> // Needed for HUGE_VAL on Linux
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigTimeHistoryCurveMerger::RigTimeHistoryCurveMerger()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigTimeHistoryCurveMerger::addCurveData(const std::vector<double>& values, const std::vector<time_t>& 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<time_t>& RigTimeHistoryCurveMerger::allTimeSteps() const
|
||||
{
|
||||
return m_allTimeSteps;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<double>& RigTimeHistoryCurveMerger::interpolatedCurveValuesForAllTimeSteps(size_t curveIdx) const
|
||||
{
|
||||
CVF_ASSERT(curveIdx < m_interpolatedValuesForAllCurves.size());
|
||||
|
||||
return m_interpolatedValuesForAllCurves[curveIdx];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double>& RigTimeHistoryCurveMerger::interpolatedCurveValuesForAllTimeSteps(size_t curveIdx)
|
||||
{
|
||||
CVF_ASSERT(curveIdx < m_interpolatedValuesForAllCurves.size());
|
||||
|
||||
return m_interpolatedValuesForAllCurves[curveIdx];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RigTimeHistoryCurveMerger::interploatedCurveCount() const
|
||||
{
|
||||
return static_cast<int>(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<double> accumulatedValidValues(dataValueCount, 1.0);
|
||||
|
||||
for (size_t curveIdx = 0; curveIdx < curveCount; curveIdx++)
|
||||
{
|
||||
std::vector<double>& 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<time_t> 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<double>& curveValues,
|
||||
const std::vector<time_t>& 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;
|
||||
}
|
||||
|
@ -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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RigCurveDataTools.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RigTimeHistoryCurveMerger
|
||||
{
|
||||
public:
|
||||
RigTimeHistoryCurveMerger();
|
||||
|
||||
|
||||
void addCurveData(const std::vector<double>& values,
|
||||
const std::vector<time_t>& timeSteps);
|
||||
|
||||
void computeInterpolatedValues();
|
||||
|
||||
RigCurveDataTools::CurveIntervals validIntervalsForAllTimeSteps() const;
|
||||
const std::vector<time_t>& allTimeSteps() const;
|
||||
const std::vector<double>& 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<double>& 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<double>& curveValues,
|
||||
const std::vector<time_t>& curveTimeSteps);
|
||||
|
||||
private:
|
||||
void computeUnionOfTimeSteps();
|
||||
|
||||
private:
|
||||
std::vector<std::pair<std::vector<double>, std::vector<time_t>>> m_originalValues;
|
||||
|
||||
RigCurveDataTools::CurveIntervals m_validIntervalsForAllTimeSteps;
|
||||
|
||||
std::vector<time_t> m_allTimeSteps;
|
||||
std::vector<std::vector<double>> m_interpolatedValuesForAllCurves;
|
||||
};
|
Loading…
Reference in New Issue
Block a user