mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#7634 Summary Reader : Handle overlapping time steps in restart data
This commit is contained in:
@@ -352,6 +352,7 @@ void RiaPreferencesSummary::defineEditorAttribute( const caf::PdmFieldHandle* fi
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiaPreferencesSummary::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
void RiaPreferencesSummary::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||||
{
|
{
|
||||||
|
uiOrdering.add( &m_useMultipleThreadsWhenLoadingSummaryCases );
|
||||||
uiOrdering.add( &m_summaryReader );
|
uiOrdering.add( &m_summaryReader );
|
||||||
|
|
||||||
if ( m_summaryReader == SummaryReaderMode::OPM_COMMON )
|
if ( m_summaryReader == SummaryReaderMode::OPM_COMMON )
|
||||||
@@ -370,8 +371,6 @@ void RiaPreferencesSummary::defineUiOrdering( QString uiConfigName, caf::PdmUiOr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uiOrdering.add( &m_useMultipleThreadsWhenLoadingSummaryCases );
|
|
||||||
|
|
||||||
uiOrdering.skipRemainingFields();
|
uiOrdering.skipRemainingFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,9 @@ bool RifSummaryReaderMultipleFiles::values( const RifEclipseSummaryAddress& resu
|
|||||||
readerValues = zeros;
|
readerValues = zeros;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto valueCount = timeStepCount( reader.get() );
|
||||||
|
readerValues.resize( valueCount );
|
||||||
|
|
||||||
values->insert( values->end(), readerValues.begin(), readerValues.end() );
|
values->insert( values->end(), readerValues.begin(), readerValues.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +95,20 @@ RiaDefines::EclipseUnitSystem RifSummaryReaderMultipleFiles::unitSystem() const
|
|||||||
return RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
|
return RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
size_t RifSummaryReaderMultipleFiles::timeStepCount( RifSummaryReaderInterface* reader ) const
|
||||||
|
{
|
||||||
|
auto it = m_valueCountForReader.find( reader );
|
||||||
|
if ( it != m_valueCountForReader.end() )
|
||||||
|
{
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -107,12 +124,11 @@ bool RifSummaryReaderMultipleFiles::createReadersAndImportMetaData( RiaThreadSaf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
calculateOverlappingTimeSteps();
|
||||||
|
|
||||||
|
// Aggregate result addresses
|
||||||
for ( const auto& reader : m_summaryReaders )
|
for ( const auto& reader : m_summaryReaders )
|
||||||
{
|
{
|
||||||
auto readerTimeSteps = reader->timeSteps( {} );
|
|
||||||
|
|
||||||
m_aggregatedTimeSteps.insert( m_aggregatedTimeSteps.end(), readerTimeSteps.begin(), readerTimeSteps.end() );
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto resultAddresses = reader->allResultAddresses();
|
auto resultAddresses = reader->allResultAddresses();
|
||||||
m_allResultAddresses.insert( resultAddresses.begin(), resultAddresses.end() );
|
m_allResultAddresses.insert( resultAddresses.begin(), resultAddresses.end() );
|
||||||
@@ -126,3 +142,48 @@ bool RifSummaryReaderMultipleFiles::createReadersAndImportMetaData( RiaThreadSaf
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
// Detect any overlapping time steps. Always use data from summary reader with the newest data, so do processing
|
||||||
|
// from the last reader to the first
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RifSummaryReaderMultipleFiles::calculateOverlappingTimeSteps()
|
||||||
|
{
|
||||||
|
if ( m_summaryReaders.empty() ) return;
|
||||||
|
|
||||||
|
auto lastRestartCase = m_summaryReaders.back().get();
|
||||||
|
auto lastRestartCaseTimeSteps = lastRestartCase->timeSteps( {} );
|
||||||
|
m_valueCountForReader[lastRestartCase] = lastRestartCaseTimeSteps.size();
|
||||||
|
|
||||||
|
time_t cutOffTime = lastRestartCaseTimeSteps.front();
|
||||||
|
for ( int i = static_cast<int>( m_summaryReaders.size() - 2 ); i >= 0; i-- )
|
||||||
|
{
|
||||||
|
auto currentReader = m_summaryReaders.at( static_cast<size_t>( i ) ).get();
|
||||||
|
auto currentTimeSteps = currentReader->timeSteps( {} );
|
||||||
|
|
||||||
|
size_t timeStepIndex = 0;
|
||||||
|
for ( auto t : currentTimeSteps )
|
||||||
|
{
|
||||||
|
if ( t < cutOffTime ) timeStepIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_valueCountForReader[currentReader] = timeStepIndex;
|
||||||
|
|
||||||
|
if ( currentTimeSteps.front() < cutOffTime )
|
||||||
|
{
|
||||||
|
cutOffTime = currentTimeSteps.front();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a vector of increasing time steps with no overlapping time steps
|
||||||
|
for ( const auto& reader : m_summaryReaders )
|
||||||
|
{
|
||||||
|
auto currentTimeSteps = reader->timeSteps( {} );
|
||||||
|
auto valueCount = m_valueCountForReader[reader.get()];
|
||||||
|
currentTimeSteps.resize( valueCount );
|
||||||
|
|
||||||
|
m_aggregatedTimeSteps.insert( m_aggregatedTimeSteps.end(), currentTimeSteps.begin(), currentTimeSteps.end() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -44,9 +44,14 @@ public:
|
|||||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
size_t timeStepCount( RifSummaryReaderInterface* reader ) const;
|
||||||
|
void calculateOverlappingTimeSteps();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> m_fileNames;
|
std::vector<std::string> m_fileNames;
|
||||||
std::vector<std::unique_ptr<RifSummaryReaderInterface>> m_summaryReaders;
|
std::vector<std::unique_ptr<RifSummaryReaderInterface>> m_summaryReaders;
|
||||||
|
|
||||||
std::vector<time_t> m_aggregatedTimeSteps;
|
std::map<RifSummaryReaderInterface*, size_t> m_valueCountForReader;
|
||||||
|
std::vector<time_t> m_aggregatedTimeSteps;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user