2017-11-08 01:43:14 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-11-08 01:43:14 -06: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 03:40:57 -05:00
|
|
|
//
|
2017-11-08 01:43:14 -06: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 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-11-08 01:43:14 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RimCalculatedSummaryCurveReader.h"
|
|
|
|
|
2023-02-26 01:08:06 -06:00
|
|
|
#include "RifEclipseSummaryAddress.h"
|
2017-11-08 01:43:14 -06:00
|
|
|
#include "RimSummaryCalculation.h"
|
|
|
|
#include "RimSummaryCalculationCollection.h"
|
2023-02-26 01:08:06 -06:00
|
|
|
#include "RimUserDefinedCalculation.h"
|
2017-11-08 01:43:14 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-08 01:43:14 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 01:08:06 -06:00
|
|
|
RifCalculatedSummaryCurveReader::RifCalculatedSummaryCurveReader( RimSummaryCalculationCollection* calculationCollection,
|
|
|
|
RimSummaryCase* summaryCase )
|
2019-09-06 03:40:57 -05:00
|
|
|
: m_calculationCollection( calculationCollection )
|
2023-02-26 01:08:06 -06:00
|
|
|
, m_summaryCase( summaryCase )
|
2017-11-08 01:43:14 -06:00
|
|
|
{
|
2023-02-26 01:08:06 -06:00
|
|
|
CAF_ASSERT( summaryCase );
|
2017-11-08 01:43:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-08 01:43:14 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-13 05:40:08 -06:00
|
|
|
std::vector<time_t> RifCalculatedSummaryCurveReader::timeSteps( const RifEclipseSummaryAddress& resultAddress ) const
|
2017-11-08 01:43:14 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RimSummaryCalculation* calc = findCalculationByName( resultAddress );
|
2023-02-26 01:08:06 -06:00
|
|
|
if ( calc && m_summaryCase )
|
2017-11-08 01:43:14 -06:00
|
|
|
{
|
2023-02-26 01:08:06 -06:00
|
|
|
RimSummaryCalculationAddress address( resultAddress );
|
|
|
|
return calc->timeSteps( m_summaryCase, address );
|
2017-11-08 01:43:14 -06:00
|
|
|
}
|
|
|
|
|
2023-02-13 05:40:08 -06:00
|
|
|
return {};
|
2017-11-08 01:43:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-08 01:43:14 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:43:15 -06:00
|
|
|
bool RifCalculatedSummaryCurveReader::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
2017-11-08 01:43:14 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RimSummaryCalculation* calc = findCalculationByName( resultAddress );
|
2023-02-26 01:08:06 -06:00
|
|
|
if ( calc && m_summaryCase )
|
2017-11-08 01:43:14 -06:00
|
|
|
{
|
2023-02-26 01:08:06 -06:00
|
|
|
RimSummaryCalculationAddress address( resultAddress );
|
|
|
|
*values = calc->values( m_summaryCase, address );
|
2017-11-08 01:43:14 -06:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-08 01:43:14 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::string RifCalculatedSummaryCurveReader::unitName( const RifEclipseSummaryAddress& resultAddress ) const
|
2017-11-08 01:43:14 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RimSummaryCalculation* calculation = findCalculationByName( resultAddress );
|
|
|
|
if ( calculation != nullptr && !calculation->unitName().isEmpty() )
|
2017-11-08 01:43:14 -06:00
|
|
|
{
|
|
|
|
return calculation->unitName().toStdString();
|
|
|
|
}
|
2017-12-11 07:54:54 -06:00
|
|
|
|
|
|
|
return "";
|
2017-11-08 01:43:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-08 01:43:14 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RifCalculatedSummaryCurveReader::buildMetaData()
|
|
|
|
{
|
|
|
|
m_allResultAddresses.clear();
|
|
|
|
|
2022-04-22 05:18:34 -05:00
|
|
|
for ( RimUserDefinedCalculation* calc : m_calculationCollection->calculations() )
|
2017-11-08 01:43:14 -06:00
|
|
|
{
|
2023-02-26 01:08:06 -06:00
|
|
|
RimSummaryCalculation* sumCalc = dynamic_cast<RimSummaryCalculation*>( calc );
|
|
|
|
CAF_ASSERT( sumCalc );
|
|
|
|
|
|
|
|
const auto& allAddresses = sumCalc->allAddressesForSummaryCase( m_summaryCase );
|
|
|
|
for ( auto calculationAddress : allAddresses )
|
|
|
|
{
|
|
|
|
if ( calculationAddress.address().isValid() )
|
|
|
|
{
|
|
|
|
m_allResultAddresses.insert( calculationAddress.address() );
|
|
|
|
}
|
|
|
|
}
|
2017-11-08 01:43:14 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-08 01:43:14 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
RimSummaryCalculation* RifCalculatedSummaryCurveReader::findCalculationByName( const RifEclipseSummaryAddress& resultAddress ) const
|
2017-11-08 01:43:14 -06:00
|
|
|
{
|
2023-02-26 01:08:06 -06:00
|
|
|
if ( !m_calculationCollection || !resultAddress.isCalculated() ) return nullptr;
|
2017-11-08 01:43:14 -06:00
|
|
|
|
2023-02-26 01:08:06 -06:00
|
|
|
return dynamic_cast<RimSummaryCalculation*>( m_calculationCollection->findCalculationById( resultAddress.id() ) );
|
2017-11-08 01:43:14 -06:00
|
|
|
}
|
2019-07-25 00:38:46 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-01-21 05:58:46 -06:00
|
|
|
RiaDefines::EclipseUnitSystem RifCalculatedSummaryCurveReader::unitSystem() const
|
2019-07-25 00:38:46 -05:00
|
|
|
{
|
2021-01-21 05:58:46 -06:00
|
|
|
return RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
|
2019-07-25 00:38:46 -05:00
|
|
|
}
|