Skip to content

Commit

Permalink
Add optional support for using visible cells as filter for grid stati…
Browse files Browse the repository at this point in the history
…stics
  • Loading branch information
magnesj committed Nov 10, 2023
1 parent 1046bcb commit 860f086
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
19 changes: 18 additions & 1 deletion ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "RimEclipseStatisticsCase.h"

#include "RiaOptionItemFactory.h"
#include "RiaResultNames.h"

#include "RicNewViewFeature.h"
Expand Down Expand Up @@ -93,6 +94,7 @@ RimEclipseStatisticsCase::RimEclipseStatisticsCase()
CAF_PDM_InitFieldNoDefault( &m_dataSourceForStatistics, "DataSourceForStatistics", "Data Source" );

CAF_PDM_InitFieldNoDefault( &m_gridCalculation, "GridCalculation", "Grid Calculation" );
CAF_PDM_InitFieldNoDefault( &m_gridCalculationFilterView, "GridCalculationFilterView", "Filter By View" );

CAF_PDM_InitScriptableFieldNoDefault( &m_selectedTimeSteps, "SelectedTimeSteps", "Time Step Selection" );
m_selectedTimeSteps.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
Expand Down Expand Up @@ -424,7 +426,7 @@ void RimEclipseStatisticsCase::computeStatistics()
stat.useZeroAsValueForInActiveCellsBasedOnUnionOfActiveCells();
}

stat.evaluateForResults( resultSpecification );
stat.evaluateForResults( resultSpecification, m_gridCalculationFilterView() );
}
//--------------------------------------------------------------------------------------------------
///
Expand Down Expand Up @@ -506,6 +508,7 @@ void RimEclipseStatisticsCase::defineUiOrdering( QString uiConfigName, caf::PdmU
if ( m_dataSourceForStatistics() == DataSourceType::GRID_CALCULATION )
{
group->add( &m_gridCalculation );
group->add( &m_gridCalculationFilterView );
}
else
{
Expand Down Expand Up @@ -622,6 +625,20 @@ QList<caf::PdmOptionItemInfo> RimEclipseStatisticsCase::calculateValueOptions( c
return options;
}

if ( &m_gridCalculationFilterView == fieldNeedingOptions )
{
QList<caf::PdmOptionItemInfo> options;

options.push_back( caf::PdmOptionItemInfo( nullptr, "None" ) );

for ( const auto& view : views() )
{
RiaOptionItemFactory::appendOptionItemFromViewNameAndCaseName( view, &options );
}

return options;
}

if ( &m_selectedDynamicProperties == fieldNeedingOptions )
{
QStringList varList =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class RimEclipseStatisticsCase : public RimEclipseCase
caf::PdmField<caf::AppEnum<DataSourceType>> m_dataSourceForStatistics;

caf::PdmPtrField<RimGridCalculation*> m_gridCalculation;
caf::PdmPtrField<RimEclipseView*> m_gridCalculationFilterView;

caf::PdmField<std::vector<int>> m_selectedTimeSteps;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "RigResultModifierFactory.h"
#include "RigStatisticsMath.h"

#include "RimEclipseView.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RimReservoirCellResultsStorage.h"

Expand Down Expand Up @@ -103,7 +104,7 @@ QString createResultNamePVal( const QString& resultName, double pValPos )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseStatisticsCaseEvaluator::evaluateForResults( const QList<ResSpec>& resultSpecification )
void RimEclipseStatisticsCaseEvaluator::evaluateForResults( const QList<ResSpec>& resultSpecification, RimEclipseView* filterView )
{
CVF_ASSERT( m_destinationCase );

Expand Down Expand Up @@ -198,11 +199,20 @@ void RimEclipseStatisticsCaseEvaluator::evaluateForResults( const QList<ResSpec>

auto cellCount = static_cast<int>( grid->cellCount() );

cvf::ref<cvf::UByteArray> visibility;
if ( filterView )
{
visibility = filterView->currentTotalCellVisibility();
}

// Loop over the cells in the grid, get the case values, and calculate the cell statistics
#pragma omp parallel for schedule( dynamic ) firstprivate( statParams, values )
for ( int cellIdx = 0; cellIdx < cellCount; cellIdx++ )
{
size_t reservoirCellIndex = grid->reservoirCellIndex( cellIdx );

if ( visibility.notNull() && !visibility->val( reservoirCellIndex ) ) continue;

if ( m_destinationCase->activeCellInfo( poroModel )->isActive( reservoirCellIndex ) )
{
// Extract the cell values from each of the cases and assemble them into one vector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class RimEclipseStatisticsCaseEvaluator

void useZeroAsValueForInActiveCellsBasedOnUnionOfActiveCells();

void evaluateForResults( const QList<ResSpec>& resultSpecification );
void evaluateForResults( const QList<ResSpec>& resultSpecification, RimEclipseView* filterView );

private:
void addNamedResults( const QList<ResSpec>& resultSpecification );
Expand Down

0 comments on commit 860f086

Please sign in to comment.