2017-10-12 07:30:37 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2017-10-12 07:30:37 +02:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2017-10-12 07:30:37 +02:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-10-12 07:30:37 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2017-10-23 14:42:38 +02:00
|
|
|
#include "RimSummaryCalculationCollection.h"
|
2017-10-12 07:30:37 +02:00
|
|
|
|
2024-10-21 14:40:25 +02:00
|
|
|
#include "Summary/RiaSummaryTools.h"
|
2024-02-26 13:55:41 +01:00
|
|
|
|
|
|
|
|
#include "RifSummaryReaderInterface.h"
|
|
|
|
|
|
2026-08-21 12:46:42 +02:00
|
|
|
#include "RimDeltaSummaryEnsemble.h"
|
2024-02-26 13:55:41 +01:00
|
|
|
#include "RimObservedSummaryData.h"
|
2017-10-23 14:42:38 +02:00
|
|
|
#include "RimSummaryCalculation.h"
|
2024-02-26 13:55:41 +01:00
|
|
|
#include "RimSummaryCase.h"
|
|
|
|
|
#include "RimSummaryCaseMainCollection.h"
|
2024-07-29 15:38:17 +02:00
|
|
|
#include "RimSummaryEnsemble.h"
|
2017-10-12 07:30:37 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_PDM_SOURCE_INIT( RimSummaryCalculationCollection, "RimSummaryCalculationCollection" );
|
2017-10-12 07:30:37 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-10-12 07:30:37 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-23 14:42:38 +02:00
|
|
|
RimSummaryCalculationCollection::RimSummaryCalculationCollection()
|
2017-10-12 07:30:37 +02:00
|
|
|
{
|
2022-01-07 08:31:52 +01:00
|
|
|
CAF_PDM_InitObject( "Calculation Collection", ":/chain.png" );
|
2017-10-12 07:30:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-10-12 07:30:37 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-04-22 12:18:34 +02:00
|
|
|
RimSummaryCalculation* RimSummaryCalculationCollection::createCalculation() const
|
2019-12-10 13:18:14 +01:00
|
|
|
{
|
2022-04-22 12:18:34 +02:00
|
|
|
return new RimSummaryCalculation;
|
2019-12-10 13:18:14 +01:00
|
|
|
}
|
|
|
|
|
|
2024-02-26 13:55:41 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSummaryCalculationCollection::updateDataDependingOnCalculations()
|
|
|
|
|
{
|
2025-07-21 15:17:00 +02:00
|
|
|
if ( calculations().empty() ) return;
|
|
|
|
|
|
2024-02-26 13:55:41 +01:00
|
|
|
// Refresh data sources tree
|
|
|
|
|
// Refresh meta data for all summary cases and rebuild AddressNodes in the summary tree
|
2025-10-14 13:25:44 +02:00
|
|
|
if ( auto summaryCaseCollection = RiaSummaryTools::summaryCaseMainCollection() )
|
2024-02-26 13:55:41 +01:00
|
|
|
{
|
2025-10-14 13:25:44 +02:00
|
|
|
auto summaryCases = summaryCaseCollection->allSummaryCases();
|
|
|
|
|
for ( RimSummaryCase* summaryCase : summaryCases )
|
2024-02-26 13:55:41 +01:00
|
|
|
{
|
2025-10-14 13:25:44 +02:00
|
|
|
if ( !summaryCase ) continue;
|
|
|
|
|
|
2025-11-19 14:30:13 +01:00
|
|
|
if ( summaryCase->showTreeNodes() )
|
2024-03-19 13:12:12 +01:00
|
|
|
{
|
2025-10-14 13:25:44 +02:00
|
|
|
if ( auto reader = summaryCase->summaryReader() )
|
|
|
|
|
{
|
|
|
|
|
reader->createAndSetAddresses();
|
|
|
|
|
}
|
|
|
|
|
summaryCase->onCalculationUpdated();
|
2024-03-19 13:12:12 +01:00
|
|
|
}
|
2024-02-26 13:55:41 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RimObservedDataCollection* observedDataCollection = RiaSummaryTools::observedDataCollection();
|
|
|
|
|
auto observedData = observedDataCollection->allObservedSummaryData();
|
|
|
|
|
for ( auto obs : observedData )
|
|
|
|
|
{
|
|
|
|
|
if ( !obs ) continue;
|
|
|
|
|
|
|
|
|
|
if ( auto reader = obs->summaryReader() )
|
|
|
|
|
{
|
2025-07-17 16:32:25 +02:00
|
|
|
reader->createAndSetAddresses();
|
2024-02-26 13:55:41 +01:00
|
|
|
obs->onCalculationUpdated();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-14 13:25:44 +02:00
|
|
|
if ( auto summaryCaseCollection = RiaSummaryTools::summaryCaseMainCollection() )
|
2024-02-26 13:55:41 +01:00
|
|
|
{
|
2026-08-21 12:46:42 +02:00
|
|
|
// A delta ensemble derives its addresses from the source ensembles, and must be updated after the source ensembles. The delta
|
|
|
|
|
// ensembles are stored after the source ensembles, as an ensemble must exist before it can be used as a source.
|
|
|
|
|
std::vector<RimSummaryEnsemble*> deltaEnsembles;
|
|
|
|
|
|
2025-10-14 13:25:44 +02:00
|
|
|
for ( auto ensemble : summaryCaseCollection->summaryEnsembles() )
|
2026-08-21 12:46:42 +02:00
|
|
|
{
|
|
|
|
|
if ( dynamic_cast<RimDeltaSummaryEnsemble*>( ensemble ) )
|
|
|
|
|
{
|
|
|
|
|
deltaEnsembles.push_back( ensemble );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ensemble->onCalculationUpdated();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( auto ensemble : deltaEnsembles )
|
2025-10-14 13:25:44 +02:00
|
|
|
{
|
|
|
|
|
ensemble->onCalculationUpdated();
|
|
|
|
|
}
|
2024-02-26 13:55:41 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-18 11:18:43 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-10-18 11:18:43 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-23 14:42:38 +02:00
|
|
|
void RimSummaryCalculationCollection::rebuildCaseMetaData()
|
2017-10-18 11:18:43 +02:00
|
|
|
{
|
2022-05-09 09:32:09 +02:00
|
|
|
ensureValidCalculationIds();
|
2024-02-26 13:55:41 +01:00
|
|
|
updateDataDependingOnCalculations();
|
2017-10-20 10:04:05 +02:00
|
|
|
}
|