2020-04-01 06:32:27 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2020- 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 "RimcSummaryCase.h"
|
|
|
|
|
2024-10-21 07:40:25 -05:00
|
|
|
#include "Summary/RiaSummaryTools.h"
|
2020-04-01 15:21:21 -05:00
|
|
|
|
2020-04-01 06:32:27 -05:00
|
|
|
#include "RifSummaryReaderInterface.h"
|
2021-12-14 04:10:19 -06:00
|
|
|
|
|
|
|
#include "RimFileSummaryCase.h"
|
2020-04-01 06:32:27 -05:00
|
|
|
#include "RimSummaryCase.h"
|
|
|
|
|
2020-04-01 08:07:54 -05:00
|
|
|
#include "RimcDataContainerDouble.h"
|
2020-04-01 07:26:36 -05:00
|
|
|
#include "RimcDataContainerString.h"
|
2020-04-01 08:07:54 -05:00
|
|
|
#include "RimcDataContainerTime.h"
|
2020-04-01 15:21:21 -05:00
|
|
|
#include "RimcSummaryResampleData.h"
|
2020-04-01 08:07:54 -05:00
|
|
|
|
2020-08-21 04:13:07 -05:00
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
2020-04-01 06:32:27 -05:00
|
|
|
|
2020-04-07 03:01:03 -05:00
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryCase, RimSummaryCase_summaryVectorValues, "summaryVectorValues" );
|
2020-04-01 06:32:27 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
RimSummaryCase_summaryVectorValues::RimSummaryCase_summaryVectorValues( caf::PdmObjectHandle* self )
|
2020-04-01 06:32:27 -05:00
|
|
|
: caf::PdmObjectMethod( self )
|
|
|
|
{
|
2021-02-03 08:40:44 -06:00
|
|
|
CAF_PDM_InitObject( "Summary Vector Values", "", "", "Get all values for a summary vector" );
|
2020-08-21 04:13:07 -05:00
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_addressString, "Address", "", "", "", "Formatted address specifying the summary vector" );
|
2020-04-01 06:32:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
caf::PdmObjectHandle* RimSummaryCase_summaryVectorValues::execute()
|
2020-04-01 06:32:27 -05:00
|
|
|
{
|
|
|
|
auto* summaryCase = self<RimSummaryCase>();
|
|
|
|
RifSummaryReaderInterface* sumReader = summaryCase->summaryReader();
|
|
|
|
|
2021-09-13 04:37:55 -05:00
|
|
|
auto adr = RifEclipseSummaryAddress::fromEclipseTextAddressParseErrorTokens( m_addressString().toStdString() );
|
2020-04-01 06:32:27 -05:00
|
|
|
|
2020-11-24 00:27:00 -06:00
|
|
|
if ( sumReader )
|
2020-04-01 06:32:27 -05:00
|
|
|
{
|
2023-09-29 10:52:31 -05:00
|
|
|
auto [isOk, values] = sumReader->values( adr );
|
|
|
|
if ( isOk )
|
2020-11-24 00:27:00 -06:00
|
|
|
{
|
2023-09-29 10:52:31 -05:00
|
|
|
return RimcDataContainerDouble::create( values );
|
2020-11-24 00:27:00 -06:00
|
|
|
}
|
2020-04-01 06:32:27 -05:00
|
|
|
}
|
|
|
|
|
2023-09-29 10:52:31 -05:00
|
|
|
return RimcDataContainerDouble::create( {} );
|
2020-04-01 06:32:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
bool RimSummaryCase_summaryVectorValues::resultIsPersistent() const
|
2020-04-01 06:32:27 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
std::unique_ptr<caf::PdmObjectHandle> RimSummaryCase_summaryVectorValues::defaultResult() const
|
2020-04-01 06:32:27 -05:00
|
|
|
{
|
|
|
|
return std::unique_ptr<caf::PdmObjectHandle>( new RimcDataContainerDouble );
|
|
|
|
}
|
2020-04-01 07:26:36 -05:00
|
|
|
|
2020-04-07 03:01:03 -05:00
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryCase, RimSummaryCase_availableAddresses, "availableAddresses" );
|
2020-04-01 07:26:36 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
RimSummaryCase_availableAddresses::RimSummaryCase_availableAddresses( caf::PdmObjectHandle* self )
|
2020-04-01 07:26:36 -05:00
|
|
|
: caf::PdmObjectMethod( self )
|
|
|
|
{
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitObject( "Available Addresses" );
|
2020-04-01 07:26:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
caf::PdmObjectHandle* RimSummaryCase_availableAddresses::execute()
|
2020-04-01 07:26:36 -05:00
|
|
|
{
|
2020-11-24 00:27:00 -06:00
|
|
|
auto* summaryCase = self<RimSummaryCase>();
|
2020-04-01 07:26:36 -05:00
|
|
|
|
|
|
|
std::vector<QString> adr;
|
2020-11-24 00:27:00 -06:00
|
|
|
|
|
|
|
RifSummaryReaderInterface* sumReader = summaryCase->summaryReader();
|
|
|
|
if ( sumReader )
|
2020-04-01 07:26:36 -05:00
|
|
|
{
|
2020-11-24 00:27:00 -06:00
|
|
|
const std::set<RifEclipseSummaryAddress>& addresses = sumReader->allResultAddresses();
|
|
|
|
for ( const auto& a : addresses )
|
|
|
|
{
|
|
|
|
adr.push_back( QString::fromStdString( a.uiText() ) );
|
|
|
|
}
|
2020-04-01 07:26:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
auto dataObject = new RimcDataContainerString();
|
|
|
|
dataObject->m_stringValues = adr;
|
|
|
|
|
|
|
|
return dataObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
bool RimSummaryCase_availableAddresses::resultIsPersistent() const
|
2020-04-01 07:26:36 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
std::unique_ptr<caf::PdmObjectHandle> RimSummaryCase_availableAddresses::defaultResult() const
|
2020-04-01 07:26:36 -05:00
|
|
|
{
|
|
|
|
return std::unique_ptr<caf::PdmObjectHandle>( new RimcDataContainerString );
|
|
|
|
}
|
2020-04-01 08:07:54 -05:00
|
|
|
|
2020-04-07 03:01:03 -05:00
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryCase, RimSummaryCase_availableTimeSteps, "availableTimeSteps" );
|
2020-04-01 08:07:54 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
RimSummaryCase_availableTimeSteps::RimSummaryCase_availableTimeSteps( caf::PdmObjectHandle* self )
|
2020-04-01 08:07:54 -05:00
|
|
|
: caf::PdmObjectMethod( self )
|
|
|
|
{
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitObject( "Available TimeSteps" );
|
2020-04-01 08:07:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
caf::PdmObjectHandle* RimSummaryCase_availableTimeSteps::execute()
|
2020-04-01 08:07:54 -05:00
|
|
|
{
|
|
|
|
auto* summaryCase = self<RimSummaryCase>();
|
|
|
|
RifSummaryReaderInterface* sumReader = summaryCase->summaryReader();
|
|
|
|
|
2020-11-24 00:27:00 -06:00
|
|
|
auto dataObject = new RimcDataContainerTime();
|
|
|
|
if ( sumReader )
|
|
|
|
{
|
|
|
|
RifEclipseSummaryAddress adr;
|
|
|
|
dataObject->m_timeValues = sumReader->timeSteps( adr );
|
|
|
|
}
|
2020-04-01 08:07:54 -05:00
|
|
|
|
|
|
|
return dataObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
bool RimSummaryCase_availableTimeSteps::resultIsPersistent() const
|
2020-04-01 08:07:54 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
std::unique_ptr<caf::PdmObjectHandle> RimSummaryCase_availableTimeSteps::defaultResult() const
|
2020-04-01 08:07:54 -05:00
|
|
|
{
|
|
|
|
return std::unique_ptr<caf::PdmObjectHandle>( new RimcDataContainerTime );
|
|
|
|
}
|
2020-04-01 15:21:21 -05:00
|
|
|
|
2020-04-07 03:01:03 -05:00
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryCase, RimSummaryCase_resampleValues, "resampleValues" );
|
2020-04-01 15:21:21 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
RimSummaryCase_resampleValues::RimSummaryCase_resampleValues( caf::PdmObjectHandle* self )
|
2020-04-01 15:21:21 -05:00
|
|
|
: caf::PdmObjectMethod( self )
|
|
|
|
{
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitObject( "Resample Values" );
|
2020-08-21 04:13:07 -05:00
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_addressString, "Address", "", "", "", "Formatted address specifying the summary vector" );
|
|
|
|
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_resamplingPeriod, "ResamplingPeriod", "", "", "", "Resampling Period" );
|
2020-04-01 15:21:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
caf::PdmObjectHandle* RimSummaryCase_resampleValues::execute()
|
2020-04-01 15:21:21 -05:00
|
|
|
{
|
|
|
|
auto* summaryCase = self<RimSummaryCase>();
|
|
|
|
RifSummaryReaderInterface* sumReader = summaryCase->summaryReader();
|
|
|
|
|
2021-09-13 04:37:55 -05:00
|
|
|
auto adr = RifEclipseSummaryAddress::fromEclipseTextAddressParseErrorTokens( m_addressString().toStdString() );
|
2020-04-01 15:21:21 -05:00
|
|
|
|
2020-11-24 00:27:00 -06:00
|
|
|
auto dataObject = new RimcSummaryResampleData();
|
2020-04-01 15:21:21 -05:00
|
|
|
|
2020-11-24 00:27:00 -06:00
|
|
|
if ( sumReader )
|
|
|
|
{
|
2023-09-29 10:52:31 -05:00
|
|
|
auto [isOk, values] = sumReader->values( adr );
|
2020-11-24 00:27:00 -06:00
|
|
|
if ( !isOk )
|
|
|
|
{
|
|
|
|
// Error message
|
|
|
|
}
|
2020-04-01 15:21:21 -05:00
|
|
|
|
2021-02-12 03:50:58 -06:00
|
|
|
const auto& timeValues = sumReader->timeSteps( adr );
|
2020-04-01 15:21:21 -05:00
|
|
|
|
2022-03-14 03:18:48 -05:00
|
|
|
QString periodString = m_resamplingPeriod().trimmed();
|
|
|
|
RiaDefines::DateTimePeriod period = RiaDefines::DateTimePeriodEnum::fromText( periodString );
|
2020-04-15 06:23:05 -05:00
|
|
|
|
2022-03-14 03:18:48 -05:00
|
|
|
if ( period != RiaDefines::DateTimePeriod::NONE )
|
2020-04-15 06:23:05 -05:00
|
|
|
{
|
2023-02-26 03:48:40 -06:00
|
|
|
auto [resampledTimeSteps, resampledValues] = RiaSummaryTools::resampledValuesForPeriod( adr, timeValues, values, period );
|
2021-02-12 03:50:58 -06:00
|
|
|
|
|
|
|
dataObject->m_timeValues = resampledTimeSteps;
|
|
|
|
dataObject->m_doubleValues = resampledValues;
|
2020-04-15 06:23:05 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-24 00:27:00 -06:00
|
|
|
dataObject->m_timeValues = timeValues;
|
|
|
|
dataObject->m_doubleValues = values;
|
2020-04-15 06:23:05 -05:00
|
|
|
}
|
2020-04-01 15:21:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return dataObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
bool RimSummaryCase_resampleValues::resultIsPersistent() const
|
2020-04-01 15:21:21 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-04-07 03:01:03 -05:00
|
|
|
std::unique_ptr<caf::PdmObjectHandle> RimSummaryCase_resampleValues::defaultResult() const
|
2020-04-01 15:21:21 -05:00
|
|
|
{
|
|
|
|
return std::unique_ptr<caf::PdmObjectHandle>( new RimcSummaryResampleData );
|
|
|
|
}
|
2021-12-14 04:10:19 -06:00
|
|
|
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryCase, RimSummaryCase_setSummaryVectorValues, "setSummaryValues" );
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimSummaryCase_setSummaryVectorValues::RimSummaryCase_setSummaryVectorValues( caf::PdmObjectHandle* self )
|
|
|
|
: caf::PdmObjectMethod( self )
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject( "Set Summary Values" );
|
|
|
|
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_addressString, "Address", "", "", "", "Formatted address specifying the summary vector" );
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_unitString, "Unit", "", "", "", "Unit" );
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_values, "Values", "", "", "", "Values" );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmObjectHandle* RimSummaryCase_setSummaryVectorValues::execute()
|
|
|
|
{
|
|
|
|
auto* summaryCase = self<RimSummaryCase>();
|
|
|
|
auto* fileSummaryCase = dynamic_cast<RimFileSummaryCase*>( summaryCase );
|
|
|
|
if ( fileSummaryCase )
|
|
|
|
{
|
2024-03-21 05:29:59 -05:00
|
|
|
bool rebuildUserInterface = true;
|
|
|
|
|
|
|
|
if ( auto reader = fileSummaryCase->summaryReader() )
|
|
|
|
{
|
|
|
|
auto allAddr = reader->allResultAddresses();
|
|
|
|
for ( auto adr : allAddr )
|
|
|
|
{
|
|
|
|
if ( adr.uiText() == m_addressString().toStdString() )
|
|
|
|
{
|
|
|
|
rebuildUserInterface = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-14 04:10:19 -06:00
|
|
|
fileSummaryCase->setSummaryData( m_addressString().toStdString(), m_unitString().toStdString(), m_values() );
|
2024-03-21 05:29:59 -05:00
|
|
|
|
|
|
|
if ( rebuildUserInterface )
|
|
|
|
{
|
|
|
|
fileSummaryCase->refreshMetaData();
|
|
|
|
}
|
2021-12-14 04:10:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimSummaryCase_setSummaryVectorValues::resultIsPersistent() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::unique_ptr<caf::PdmObjectHandle> RimSummaryCase_setSummaryVectorValues::defaultResult() const
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimSummaryCase_setSummaryVectorValues::isNullptrValidResult() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|