@@ -614,6 +614,11 @@ void RimStatisticsContourMap::onComputeStatisticsClicked()
614614void RimStatisticsContourMap::computeStatistics ()
615615{
616616 computeStatisticsForMaps ( { this } );
617+
618+ if ( auto ensemble = firstAncestorOrThisOfType<RimReservoirGridEnsemble>() )
619+ {
620+ ensemble->reloadMetaDataIfNeeded ();
621+ }
617622}
618623
619624// --------------------------------------------------------------------------------------------------
@@ -682,7 +687,7 @@ void RimStatisticsContourMap::computeStatisticsForMaps( const std::vector<RimSta
682687
683688 // The bounding box is empty unless the primary case is open with active cell info
684689 cvf::BoundingBox gridBoundingBox = primaryCase->activeCellsBoundingBox ();
685- gridBoundingBox.expandPercent ( map->m_boundingBoxExpPercent () );
690+ gridBoundingBox.expandPercent ( map->m_boundingBoxExpPercent (), map-> m_boundingBoxExpPercent () );
686691
687692 double sampleSpacing = 1.0 ;
688693 if ( auto mainGrid = primaryCase->mainGrid () ) sampleSpacing = map->sampleSpacingFactor () * mainGrid->characteristicIJCellSize ();
@@ -722,12 +727,7 @@ void RimStatisticsContourMap::computeStatisticsForMaps( const std::vector<RimSta
722727 RiaLogging::info ( std::format ( " Computing statistics for {} ensemble contour map(s)" , contexts.size () ) );
723728
724729 // All maps belong to the same ensemble, so the realization cases are shared
725- auto cases = contexts.front ().map ->ensembleCases ();
726- auto casesInViews = contexts.front ().map ->ensembleCasesInViews ();
727-
728- std::set<RimEclipseCase*> primaryCases;
729- for ( const auto & ctx : contexts )
730- primaryCases.insert ( ctx.map ->eclipseCase () );
730+ auto cases = contexts.front ().map ->ensembleCases ();
731731
732732 const size_t nCases = cases.size ();
733733 caf::ProgressInfo progInfo ( nCases, QString ( " Reading Eclipse Ensemble" ) );
@@ -739,6 +739,8 @@ void RimStatisticsContourMap::computeStatisticsForMaps( const std::vector<RimSta
739739 {
740740 auto task = progInfo.task ( QString ( " Processing Case %1 of %2" ).arg ( i++ ).arg ( nCases ) );
741741
742+ bool closeCase = !eCase->isReservoirCaseOpen ();
743+
742744 RifReaderSettings oldSettings = eCase->readerSettings ();
743745 eCase->setReaderSettings ( readerSettings );
744746
@@ -796,7 +798,7 @@ void RimStatisticsContourMap::computeStatisticsForMaps( const std::vector<RimSta
796798 // Release the grid data for cases that were opened only to compute statistics. A case is kept open if it has
797799 // its own views, if it is the primary case of one of the contour maps, or if it is displayed in one of the
798800 // ensemble views.
799- if ( eCase-> views (). empty () && !primaryCases. contains ( eCase ) && !casesInViews. contains ( eCase ) )
801+ if ( closeCase )
800802 {
801803 eCase->closeReservoirCase ();
802804 }
@@ -981,6 +983,12 @@ void RimStatisticsContourMap::ensureResultsComputed()
981983 }
982984
983985 computeStatisticsForMaps ( maps );
986+
987+ // contour map calculations on shared grids clears the ensemble meta data, reload it
988+ if ( auto ensemble = firstAncestorOrThisOfType<RimReservoirGridEnsemble>() )
989+ {
990+ ensemble->reloadMetaDataIfNeeded ();
991+ }
984992}
985993
986994// --------------------------------------------------------------------------------------------------
0 commit comments