mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
* Removes obsolete code * Return first non-empty return value from reader * Simplifies water cut curve visibility check * Defers the page update until after all plots have been added. * Add settings to control number of threads * Refactors ensemble curve handling and visibility Improves the efficiency of ensemble curve set management by separating realization and statistics curves into distinct collections. This allows for more targeted operations, such as selectively showing/hiding realization curves without affecting statistics. Also defers data loading of curves until they are actually displayed, optimizing performance. The visibility updates are modified to optionally skip updating the parent plot, providing more control over replotting behavior and preventing unnecessary updates.
154 lines
5.8 KiB
C++
154 lines
5.8 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2021- 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 "RifMultipleSummaryReaders.h"
|
|
|
|
#include "RimCalculatedSummaryCurveReader.h"
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RifMultipleSummaryReaders::RifMultipleSummaryReaders() = default;
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RifMultipleSummaryReaders::addReader( std::unique_ptr<RifSummaryReaderInterface> reader )
|
|
{
|
|
if ( findReader( reader->serialNumber() ) != nullptr ) return;
|
|
|
|
m_readers.push_back( std::move( reader ) );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RifSummaryReaderInterface* RifMultipleSummaryReaders::findReader( int serialNumber ) const
|
|
{
|
|
auto reader = std::find_if( m_readers.begin(),
|
|
m_readers.end(),
|
|
[serialNumber]( const std::unique_ptr<RifSummaryReaderInterface>& r )
|
|
{ return r->serialNumber() == serialNumber; } );
|
|
if ( reader != m_readers.end() )
|
|
{
|
|
return reader->get();
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RifMultipleSummaryReaders::removeReader( int serialNumber )
|
|
{
|
|
auto reader = std::find_if( m_readers.begin(),
|
|
m_readers.end(),
|
|
[serialNumber]( const std::unique_ptr<RifSummaryReaderInterface>& r )
|
|
{ return r->serialNumber() == serialNumber; } );
|
|
|
|
if ( reader != m_readers.end() )
|
|
{
|
|
m_readers.erase( reader );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<time_t> RifMultipleSummaryReaders::timeSteps( const RifEclipseSummaryAddress& resultAddress ) const
|
|
{
|
|
for ( const auto& r : m_readers )
|
|
{
|
|
const auto& timeSteps = r->timeSteps( resultAddress );
|
|
if ( !timeSteps.empty() ) return timeSteps;
|
|
}
|
|
|
|
return {};
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::pair<bool, std::vector<double>> RifMultipleSummaryReaders::values( const RifEclipseSummaryAddress& resultAddress ) const
|
|
{
|
|
for ( const auto& r : m_readers )
|
|
{
|
|
const auto& okAndValues = r->values( resultAddress );
|
|
if ( okAndValues.first && !okAndValues.second.empty() ) return okAndValues;
|
|
}
|
|
|
|
return { false, {} };
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::string RifMultipleSummaryReaders::unitName( const RifEclipseSummaryAddress& resultAddress ) const
|
|
{
|
|
for ( const auto& r : m_readers )
|
|
{
|
|
auto name = r->unitName( resultAddress );
|
|
if ( !name.empty() ) return name;
|
|
}
|
|
|
|
return {};
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RiaDefines::EclipseUnitSystem RifMultipleSummaryReaders::unitSystem() const
|
|
{
|
|
CVF_ASSERT( !m_readers.empty() );
|
|
|
|
return m_readers.at( 0 )->unitSystem();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RifMultipleSummaryReaders::createAndSetAddresses()
|
|
{
|
|
m_allErrorAddresses.clear();
|
|
m_allResultAddresses.clear();
|
|
|
|
for ( auto& reader : m_readers )
|
|
{
|
|
reader->createAndSetAddresses();
|
|
|
|
auto resultAddresses = reader->allResultAddresses();
|
|
m_allResultAddresses.insert( resultAddresses.begin(), resultAddresses.end() );
|
|
|
|
auto errorResultAddresses = reader->allErrorAddresses();
|
|
m_allErrorAddresses.insert( errorResultAddresses.begin(), errorResultAddresses.end() );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
size_t RifMultipleSummaryReaders::keywordCount() const
|
|
{
|
|
for ( const auto& r : m_readers )
|
|
{
|
|
if ( r->keywordCount() > 0 ) return r->keywordCount();
|
|
}
|
|
|
|
return 0;
|
|
}
|