mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
#14345 Add debug logging of value counts used in aggregations and histogram statistics
Log at debug level, for each case and time step, how many input values contribute to a grid calculation aggregation and how many were replaced with the default value (non-visible cells and undefined values). Also log the sum and number of values used when computing visible cells statistics, to allow comparison with the histogram sum in the 3d view.
This commit is contained in:
1 parent
0ad61a004a
commit
be9969d5b4
3 files changed
+40
-13
No files matched your search
@@ -698,12 +698,13 @@ void RimGridCalculation::replaceFilteredValuesWithVector( const std::vector<doub
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
/// Replace values for non-visible cells with the given default value. Returns the number of replaced
|
||||
/// values.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCalculation::replaceFilteredValuesWithDefaultValue( double defaultValue,
|
||||
cvf::ref<cvf::UByteArray> visibility,
|
||||
std::vector<double>& resultValues,
|
||||
RigActiveCellInfo* activeCellInfo )
|
||||
size_t RimGridCalculation::replaceFilteredValuesWithDefaultValue( double defaultValue,
|
||||
cvf::ref<cvf::UByteArray> visibility,
|
||||
std::vector<double>& resultValues,
|
||||
RigActiveCellInfo* activeCellInfo )
|
||||
|
||||
{
|
||||
auto activeReservoirCellIndices = activeCellInfo->activeReservoirCellIndices();
|
||||
@@ -711,15 +712,20 @@ void RimGridCalculation::replaceFilteredValuesWithDefaultValue( double
|
||||
|
||||
CAF_ASSERT( numActiveCells == (int)resultValues.size() );
|
||||
|
||||
#pragma omp parallel for
|
||||
size_t replacedCount = 0;
|
||||
|
||||
#pragma omp parallel for reduction( + : replacedCount )
|
||||
for ( int i = 0; i < numActiveCells; i++ )
|
||||
{
|
||||
const auto reservoirCellIndex = activeReservoirCellIndices[i];
|
||||
if ( !visibility->val( reservoirCellIndex.value() ) )
|
||||
{
|
||||
resultValues[i] = defaultValue;
|
||||
replacedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return replacedCount;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -961,17 +967,30 @@ bool RimGridCalculation::calculateForCases( const std::vector<RimEclipseCase*>&
|
||||
}
|
||||
else if ( hasAggregationExpression )
|
||||
{
|
||||
const double defaultValue = 0.0;
|
||||
const double defaultValue = 0.0;
|
||||
size_t nonVisibleCount = 0;
|
||||
if ( inputValueVisibilityFilter )
|
||||
{
|
||||
auto activeCellInfo = calculationCase->eclipseCaseData()->activeCellInfo( porosityModel );
|
||||
replaceFilteredValuesWithDefaultValue( defaultValue, inputValueVisibilityFilter, dataForVariable, activeCellInfo );
|
||||
nonVisibleCount =
|
||||
replaceFilteredValuesWithDefaultValue( defaultValue, inputValueVisibilityFilter, dataForVariable, activeCellInfo );
|
||||
}
|
||||
|
||||
// Aggregation functions include all values in the vector. Replace undefined values with the
|
||||
// default value to avoid contaminating aggregated values like sum() with infinity. Undefined
|
||||
// values are ignored by other statistics computations, like the histogram in the 3d view.
|
||||
invalidValueCountPerVariable[i] += replaceInvalidValuesWithDefaultValue( defaultValue, dataForVariable );
|
||||
const size_t invalidCount = replaceInvalidValuesWithDefaultValue( defaultValue, dataForVariable );
|
||||
invalidValueCountPerVariable[i] += invalidCount;
|
||||
|
||||
RiaLogging::debug( std::format( " Case '{}', time step {}: variable '{}': {} of {} values used in aggregation "
|
||||
"({} non-visible and {} undefined values replaced with 0.0)",
|
||||
calculationCase->caseUserDescription().toStdString(),
|
||||
tsId,
|
||||
v->name().toStdString(),
|
||||
dataForVariable.size() - nonVisibleCount - invalidCount,
|
||||
dataForVariable.size(),
|
||||
nonVisibleCount,
|
||||
invalidCount ) );
|
||||
}
|
||||
|
||||
dataForAllVariables.push_back( dataForVariable );
|
||||
|
||||
@@ -120,10 +120,10 @@ protected:
|
||||
std::vector<double>& resultValues,
|
||||
RigActiveCellInfo* activeCellInfo );
|
||||
|
||||
static void replaceFilteredValuesWithDefaultValue( double defaultValue,
|
||||
cvf::ref<cvf::UByteArray> visibility,
|
||||
std::vector<double>& resultValues,
|
||||
RigActiveCellInfo* activeCellInfo );
|
||||
static size_t replaceFilteredValuesWithDefaultValue( double defaultValue,
|
||||
cvf::ref<cvf::UByteArray> visibility,
|
||||
std::vector<double>& resultValues,
|
||||
RigActiveCellInfo* activeCellInfo );
|
||||
|
||||
using DefaultValueConfig = std::pair<RimGridCalculation::DefaultValueType, double>;
|
||||
DefaultValueConfig defaultValueConfiguration() const;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "RigEclipseNativeVisibleCellsStatCalc.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaResultNames.h"
|
||||
|
||||
#include "RigActiveCellInfo.h"
|
||||
@@ -27,6 +28,7 @@
|
||||
#include "RigWeightedMeanCalc.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <format>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -104,6 +106,12 @@ void RigEclipseNativeVisibleCellsStatCalc::valueSumAndSampleCount( size_t timeSt
|
||||
traverseCells( acc, timeStepIndex );
|
||||
valueSum = acc.valueSum;
|
||||
sampleCount = acc.sampleCount;
|
||||
|
||||
RiaLogging::debug( std::format( "Visible cells statistics for '{}', time step {}: sum = {}, number of values used = {}",
|
||||
m_resultAddress.resultName().toStdString(),
|
||||
timeStepIndex,
|
||||
valueSum,
|
||||
sampleCount ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user