2017-09-15 14:26:06 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2017- Statoil ASA
|
2019-06-07 14:41:55 +02:00
|
|
|
//
|
2017-09-15 14:26:06 +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-06-07 14:41:55 +02:00
|
|
|
//
|
2017-09-15 14:26:06 +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-06-07 14:41:55 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-09-15 14:26:06 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "RifSummaryReaderInterface.h"
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include <QDateTime>
|
|
|
|
|
|
2024-10-22 16:24:11 +02:00
|
|
|
int RifSummaryReaderInterface::m_nextSerialNumber = 0;
|
|
|
|
|
|
2017-09-15 14:26:06 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-06-07 14:41:55 +02:00
|
|
|
///
|
2017-09-15 14:26:06 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-06-25 15:14:47 +02:00
|
|
|
const std::set<RifEclipseSummaryAddress>& RifSummaryReaderInterface::allResultAddresses() const
|
2017-09-15 14:26:06 +02:00
|
|
|
{
|
|
|
|
|
return m_allResultAddresses;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-25 11:10:03 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-06-07 14:41:55 +02:00
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
const std::set<RifEclipseSummaryAddress>& RifSummaryReaderInterface::allErrorAddresses() const
|
|
|
|
|
{
|
|
|
|
|
return m_allErrorAddresses;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
2018-05-25 11:10:03 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
RifEclipseSummaryAddress RifSummaryReaderInterface::errorAddress( const RifEclipseSummaryAddress& resultAddress ) const
|
2018-05-25 11:10:03 +02:00
|
|
|
{
|
|
|
|
|
RifEclipseSummaryAddress errAddr = resultAddress;
|
|
|
|
|
errAddr.setAsErrorResult();
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
return m_allErrorAddresses.find( errAddr ) != m_allErrorAddresses.end() ? errAddr : RifEclipseSummaryAddress();
|
2018-05-25 11:10:03 +02:00
|
|
|
}
|
|
|
|
|
|
2024-02-26 13:55:41 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-07-17 16:32:25 +02:00
|
|
|
void RifSummaryReaderInterface::createAndSetAddresses()
|
2024-02-26 13:55:41 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-17 16:32:25 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RifSummaryReaderInterface::createAddressesIfRequired()
|
|
|
|
|
{
|
|
|
|
|
if ( m_allResultAddresses.empty() )
|
|
|
|
|
{
|
|
|
|
|
createAndSetAddresses();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-21 12:46:42 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RifSummaryReaderInterface::refreshCalculatedAddresses()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-22 16:24:11 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
int RifSummaryReaderInterface::serialNumber() const
|
|
|
|
|
{
|
|
|
|
|
return m_serialNumber;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-17 16:32:25 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
size_t RifSummaryReaderInterface::dataObjectCount() const
|
|
|
|
|
{
|
|
|
|
|
if ( !m_allResultAddresses.empty() ) return m_allResultAddresses.size();
|
|
|
|
|
|
|
|
|
|
// Fallback to keyword count if no addresses are available. This can happen if an ensemble creates addresses for only a single realization.
|
|
|
|
|
return keywordCount();
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-22 16:24:11 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-10-23 15:45:33 +02:00
|
|
|
void RifSummaryReaderInterface::increaseSerialNumber()
|
2024-10-22 16:24:11 +02:00
|
|
|
{
|
2026-08-24 14:32:17 +02:00
|
|
|
#pragma omp critical( critical_section_RifSummaryReaderInterface_serialNumber )
|
2024-10-22 16:24:11 +02:00
|
|
|
m_serialNumber = m_nextSerialNumber++;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-23 15:45:33 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RifSummaryReaderInterface::RifSummaryReaderInterface()
|
|
|
|
|
{
|
|
|
|
|
increaseSerialNumber();
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 14:26:06 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-06-07 14:41:55 +02:00
|
|
|
///
|
2017-09-15 14:26:06 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
bool RifSummaryReaderInterface::hasAddress( const RifEclipseSummaryAddress& resultAddress ) const
|
2017-09-15 14:26:06 +02:00
|
|
|
{
|
2022-05-03 08:55:31 +02:00
|
|
|
static const RifEclipseSummaryAddress defaultAdr = RifEclipseSummaryAddress();
|
|
|
|
|
if ( resultAddress == defaultAdr ) return true;
|
|
|
|
|
|
2025-07-17 16:32:25 +02:00
|
|
|
if ( !m_allResultAddresses.empty() )
|
|
|
|
|
{
|
|
|
|
|
return ( m_allResultAddresses.count( resultAddress ) > 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This is a fallback for cases where no addresses are present, such as when the summary reader is not yet initialized.
|
|
|
|
|
// This function should not be used in performance-critical code paths.
|
|
|
|
|
const auto& [isOk, vals] = values( resultAddress );
|
|
|
|
|
return isOk && !vals.empty();
|
2017-09-15 14:26:06 +02:00
|
|
|
}
|