#14345 Use cell filter geometry for grid calculation visibility

The visibility mask for 'filter by view' was taken from the view's
visible cells, which are limited to the active cells of the view's
case. When applying the calculation to additional cases with different
ACTNUM, cells inside the filter geometry that are inactive in the
view's case were excluded from the aggregation for cases where they are
active, giving too low sums.

Build the mask from the cell filter geometry (RANGE_FILTERED +
RANGE_FILTERED_INACTIVE) instead, so each calculation case contributes
its own active cells inside the filters. Property filters in the view
no longer affect the calculation. The result filtering now uses the
same mask as the input filtering, also when the visibility filter is
provided by the caller.
This commit is contained in:
Kristian Bendiksen committed 2026-09-16 10:53:31 +02:00
1 parent be9969d5b4
commit da28ffe613
2 files changed
+20 -9

No files matched your search

@@ -250,10 +250,23 @@ bool RimGridCalculation::calculate()
}
}
cvf::UByteArray* inputValueVisibilityFilter = nullptr;
cvf::ref<cvf::UByteArray> inputValueVisibilityFilter;
if ( m_cellFilterView() )
{
inputValueVisibilityFilter = m_cellFilterView()->currentTotalCellVisibility().p();
if ( auto eclipseView = dynamic_cast<RimEclipseView*>( m_cellFilterView() ) )
{
// Use the cell filter geometry, independent of the active cells in the view's case. Cells inside the
// filters that are inactive in the view's case can be active in other calculation cases, and must be
// included when the calculation is applied to additional cases.
inputValueVisibilityFilter = new cvf::UByteArray;
eclipseView->calculateCellVisibility( inputValueVisibilityFilter.p(),
{ RANGE_FILTERED, RANGE_FILTERED_INACTIVE },
eclipseView->currentTimeStep() );
}
else
{
inputValueVisibilityFilter = m_cellFilterView()->currentTotalCellVisibility();
}
}
std::optional<std::vector<size_t>> timeSteps = std::nullopt;
@@ -270,7 +283,7 @@ bool RimGridCalculation::calculate()
}
bool evaluateDependentCalculations = true;
return calculateForCases( outputEclipseCases(), inputValueVisibilityFilter, timeSteps, evaluateDependentCalculations );
return calculateForCases( outputEclipseCases(), inputValueVisibilityFilter.p(), timeSteps, evaluateDependentCalculations );
}
//--------------------------------------------------------------------------------------------------
@@ -752,7 +765,7 @@ size_t RimGridCalculation::replaceInvalidValuesWithDefaultValue( double defaultV
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCalculation::filterResults( RimGridView* cellFilterView,
void RimGridCalculation::filterResults( cvf::UByteArray* visibility,
const std::vector<std::vector<double>>& values,
size_t timeStep,
RimGridCalculation::DefaultValueType defaultValueType,
@@ -762,8 +775,6 @@ void RimGridCalculation::filterResults( RimGridView*
RimEclipseCase* outputEclipseCase ) const
{
auto visibility = cellFilterView->currentTotalCellVisibility();
auto activeCellInfo = outputEclipseCase->eclipseCaseData()->activeCellInfo( porosityModel );
if ( defaultValueType == RimGridCalculation::DefaultValueType::FROM_PROPERTY )
@@ -1034,9 +1045,9 @@ bool RimGridCalculation::calculateForCases( const std::vector<RimEclipseCase*>&
}
}
if ( m_cellFilterView() && !resultValues.empty() )
if ( inputValueVisibilityFilter && !resultValues.empty() )
{
filterResults( m_cellFilterView(),
filterResults( inputValueVisibilityFilter,
dataForAllVariables,
tsId,
m_defaultValueType(),
@@ -106,7 +106,7 @@ protected:
RimEclipseCase* sourceCase,
RimEclipseCase* destinationCase ) const;
void filterResults( RimGridView* cellFilterView,
void filterResults( cvf::UByteArray* visibility,
const std::vector<std::vector<double>>& values,
size_t timeStep,
RimGridCalculation::DefaultValueType defaultValueType,