mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 15:10:22 -05:00
Introduce RimReservoirGridEnsemble and RimReservoirGridEnsembleBase to manage ensembles of grid-only Eclipse cases. Enable detection of identical grids for shared operations and statistics. Integrate grid ensembles into project structure, UI, and menu system. Refactor statistics and view handling to support both case groups and grid ensembles via a common interface. Add deferred grid loading, robust case referencing, and migration for well data source fields. New features and menu items allow creation and management of grid ensembles from file sets, enabling new workflows for grid-only ensemble analysis.
143 lines
5.4 KiB
C++
143 lines
5.4 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2025 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 "RimEnsembleFileSetTools.h"
|
|
|
|
#include "Summary/RiaSummaryPlotTools.h"
|
|
#include "Summary/RiaSummaryTools.h"
|
|
|
|
#include "Ensemble/RimSummaryFileSetEnsemble.h"
|
|
#include "EnsembleFileSet/RimEnsembleFileSet.h"
|
|
#include "EnsembleFileSet/RimEnsembleFileSetCollection.h"
|
|
#include "RiaEnsembleNameTools.h"
|
|
#include "RimEclipseCaseCollection.h"
|
|
#include "RimOilField.h"
|
|
#include "RimProject.h"
|
|
#include "RimReservoirGridEnsemble.h"
|
|
#include "RimSummaryCaseMainCollection.h"
|
|
|
|
namespace RimEnsembleFileSetTools
|
|
{
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<RimSummaryEnsemble*> createSummaryEnsemblesFromFileSets( const std::vector<RimEnsembleFileSet*> fileSets )
|
|
{
|
|
auto sumCaseMainColl = RiaSummaryTools::summaryCaseMainCollection();
|
|
if ( !sumCaseMainColl ) return {};
|
|
|
|
std::vector<RimSummaryEnsemble*> ensembles;
|
|
for ( auto fileSet : fileSets )
|
|
{
|
|
auto ensemble = new RimSummaryFileSetEnsemble();
|
|
ensemble->setEnsembleFileSet( fileSet );
|
|
sumCaseMainColl->addEnsemble( ensemble );
|
|
sumCaseMainColl->updateEnsembleNames();
|
|
ensemble->loadDataAndUpdate();
|
|
ensembles.push_back( ensemble );
|
|
}
|
|
|
|
sumCaseMainColl->updateAllRequiredEditors();
|
|
|
|
return ensembles;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<RimEnsembleFileSet*> createEnsembleFileSets( const QStringList& fileNames, RiaDefines::EnsembleGroupingMode groupingMode )
|
|
{
|
|
std::vector<RimEnsembleFileSet*> fileSets;
|
|
|
|
auto collection = RimProject::current()->ensembleFileSetCollection();
|
|
auto grouping = RiaEnsembleNameTools::groupFilesByEnsembleName( fileNames, groupingMode );
|
|
for ( const auto& [groupName, fileNames] : grouping )
|
|
{
|
|
auto ensembleFileSet = new RimEnsembleFileSet();
|
|
ensembleFileSet->setName( groupName );
|
|
ensembleFileSet->setGroupingMode( groupingMode );
|
|
ensembleFileSet->findAndSetPathPatternAndRangeString( fileNames );
|
|
|
|
collection->addFileSet( ensembleFileSet );
|
|
|
|
fileSets.push_back( ensembleFileSet );
|
|
}
|
|
|
|
collection->updateFileSetNames();
|
|
collection->updateAllRequiredEditors();
|
|
|
|
return fileSets;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<RimReservoirGridEnsemble*> createGridEnsemblesFromFileSets( const std::vector<RimEnsembleFileSet*> fileSets )
|
|
{
|
|
RimProject* project = RimProject::current();
|
|
RimEclipseCaseCollection* eclipseCaseColl = project->activeOilField()->analysisModels();
|
|
if ( !eclipseCaseColl ) return {};
|
|
|
|
std::vector<RimReservoirGridEnsemble*> ensembles;
|
|
for ( auto fileSet : fileSets )
|
|
{
|
|
auto ensemble = new RimReservoirGridEnsemble();
|
|
ensemble->setEnsembleFileSet( fileSet );
|
|
|
|
project->assignIdToCaseGroup( ensemble );
|
|
eclipseCaseColl->reservoirGridEnsembles.push_back( ensemble );
|
|
|
|
ensemble->loadDataAndUpdate();
|
|
ensembles.push_back( ensemble );
|
|
}
|
|
|
|
eclipseCaseColl->updateAllRequiredEditors();
|
|
|
|
return ensembles;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimEnsembleFileSet* createEnsembleFileSetFromOpm( const QString& pathPattern, const QString& name )
|
|
{
|
|
auto collection = RimProject::current()->ensembleFileSetCollection();
|
|
auto ensembleFileSet = new RimEnsembleFileSet();
|
|
ensembleFileSet->setAutoName( false );
|
|
ensembleFileSet->setName( name );
|
|
ensembleFileSet->setGroupingMode( RiaDefines::EnsembleGroupingMode::RESINSIGHT_OPMFLOW_STRUCTURE );
|
|
ensembleFileSet->setPathPattern( pathPattern );
|
|
|
|
collection->addFileSet( ensembleFileSet );
|
|
collection->updateFileSetNames();
|
|
collection->updateAllRequiredEditors();
|
|
|
|
return ensembleFileSet;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QList<caf::PdmOptionItemInfo> ensembleFileSetOptions()
|
|
{
|
|
return RimProject::current()->ensembleFileSetCollection()->ensembleFileSetOptions();
|
|
}
|
|
|
|
} // namespace RimEnsembleFileSetTools
|