mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 07:00:17 -05:00
- Move depthTypeAbbreviation(), computePressureSamplesPerCase() and computeMeanPressurePerCase() out of RimParameterRftCrossPlot into a new standalone RimRftCrossPlotTools namespace, shared by RimParameterRftCrossPlot and RimRftTornadoPlot (removing duplicated code in the latter). - Extract pure, reader-independent helpers filterPressuresByDepthRange() and computeMean() so the depth filtering and averaging logic can be unit tested without RFT reader/ensemble mocks. - Add RimRftCrossPlotTools-Test.cpp with gtest cases covering depth range filtering (disabled, inclusive bounds, out-of-range, mismatched sizes) and mean computation (empty/normal), plus depth type abbreviation. Move RimWellLogRftCurve::rftCurveDepthValues into RimRftCrossPlotTools This static helper's only caller was already RimRftCrossPlotTools::computePressureSamplesPerCase, so move it alongside the other RFT cross plot/tornado plot helpers for consistency.
106 lines
4.9 KiB
C++
106 lines
4.9 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2026 Equinor 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 "gtest/gtest.h"
|
|
|
|
#include "RimRftCrossPlotTools.h"
|
|
|
|
#include <limits>
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
/// When depth-range filtering is disabled, all pressures are returned unmodified.
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RimRftCrossPlotToolsTest, FilterPressuresByDepthRange_DisabledReturnsAllSamples )
|
|
{
|
|
std::vector<double> depths{ 1000.0, 2000.0, 3000.0 };
|
|
std::vector<double> pressures{ 10.0, 20.0, 30.0 };
|
|
|
|
auto filtered = RimRftCrossPlotTools::filterPressuresByDepthRange( depths, pressures, false, 1500.0, 2500.0 );
|
|
|
|
EXPECT_EQ( pressures, filtered );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
/// When enabled, only pressures whose depth falls within [min, max] (inclusive) are returned.
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RimRftCrossPlotToolsTest, FilterPressuresByDepthRange_FiltersByInclusiveRange )
|
|
{
|
|
std::vector<double> depths{ 1000.0, 1500.0, 2000.0, 2500.0, 3000.0 };
|
|
std::vector<double> pressures{ 10.0, 15.0, 20.0, 25.0, 30.0 };
|
|
|
|
auto filtered = RimRftCrossPlotTools::filterPressuresByDepthRange( depths, pressures, true, 1500.0, 2500.0 );
|
|
|
|
std::vector<double> expected{ 15.0, 20.0, 25.0 };
|
|
EXPECT_EQ( expected, filtered );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
/// Depths outside the requested range are excluded.
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RimRftCrossPlotToolsTest, FilterPressuresByDepthRange_ExcludesOutsideRange )
|
|
{
|
|
std::vector<double> depths{ 500.0, 4000.0 };
|
|
std::vector<double> pressures{ 5.0, 40.0 };
|
|
|
|
auto filtered = RimRftCrossPlotTools::filterPressuresByDepthRange( depths, pressures, true, 1000.0, 3000.0 );
|
|
|
|
EXPECT_TRUE( filtered.empty() );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
/// Mismatched depths/pressures sizes cannot be aligned, so filtering returns an empty result.
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RimRftCrossPlotToolsTest, FilterPressuresByDepthRange_MismatchedSizesReturnsEmpty )
|
|
{
|
|
std::vector<double> depths{ 1000.0, 2000.0 };
|
|
std::vector<double> pressures{ 10.0 };
|
|
|
|
auto filtered = RimRftCrossPlotTools::filterPressuresByDepthRange( depths, pressures, true, 0.0, 5000.0 );
|
|
|
|
EXPECT_TRUE( filtered.empty() );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
/// The mean of an empty sample set is defined as infinity (used as a "no data" sentinel).
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RimRftCrossPlotToolsTest, ComputeMean_EmptyReturnsInfinity )
|
|
{
|
|
std::vector<double> samples;
|
|
|
|
EXPECT_EQ( std::numeric_limits<double>::infinity(), RimRftCrossPlotTools::computeMean( samples ) );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
/// The mean of a normal set of samples is the arithmetic average.
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RimRftCrossPlotToolsTest, ComputeMean_NormalAverage )
|
|
{
|
|
std::vector<double> samples{ 10.0, 20.0, 30.0 };
|
|
|
|
EXPECT_DOUBLE_EQ( 20.0, RimRftCrossPlotTools::computeMean( samples ) );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
/// The depth type abbreviation used in axis/plot titles distinguishes MD from TVD.
|
|
//--------------------------------------------------------------------------------------------------
|
|
TEST( RimRftCrossPlotToolsTest, DepthTypeAbbreviation )
|
|
{
|
|
EXPECT_EQ( QString( "MD" ), RimRftCrossPlotTools::depthTypeAbbreviation( RiaDefines::DepthType::MEASURED_DEPTH ) );
|
|
EXPECT_EQ( QString( "TVD" ), RimRftCrossPlotTools::depthTypeAbbreviation( RiaDefines::DepthType::TRUE_VERTICAL_DEPTH ) );
|
|
}
|