mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#7912 Summary Data Import : Map from eclAdr to keyword
This commit is contained in:
parent
2dbe0a0c9c
commit
737ee811fa
@ -93,7 +93,7 @@ bool RifOpmCommonEclipseSummary::open( const QString& headerFileName,
|
||||
try
|
||||
{
|
||||
auto temporarySummaryFile =
|
||||
std::make_unique<Opm::EclIO::ESmry>(headerFileName.toStdString(), includeRestartFiles );
|
||||
std::make_unique<Opm::EclIO::ESmry>( headerFileName.toStdString(), includeRestartFiles );
|
||||
|
||||
temporarySummaryFile->make_esmry_file();
|
||||
|
||||
@ -132,31 +132,21 @@ const std::vector<time_t>& RifOpmCommonEclipseSummary::timeSteps( const RifEclip
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifOpmCommonEclipseSummary::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
{
|
||||
if ( m_exteSmry )
|
||||
auto it = m_adrToKeyword.find( resultAddress );
|
||||
if ( it != m_adrToKeyword.end() )
|
||||
{
|
||||
auto it = m_adrToSummaryNodeIndex.find( resultAddress );
|
||||
if ( it != m_adrToSummaryNodeIndex.end() )
|
||||
auto keyword = it->second;
|
||||
if ( m_exteSmry )
|
||||
{
|
||||
// auto index = it->second;
|
||||
// auto node = m_exteSmry->summaryNodeList()[index];
|
||||
// auto fileValues = m_exteSmry->get( node );
|
||||
// values->insert( values->begin(), fileValues.begin(), fileValues.end() );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( m_eSmry )
|
||||
{
|
||||
auto it = m_adrToSummaryNodeIndex.find( resultAddress );
|
||||
if ( it != m_adrToSummaryNodeIndex.end() )
|
||||
{
|
||||
auto index = it->second;
|
||||
auto node = m_eSmry->summaryNodeList()[index];
|
||||
auto fileValues = m_eSmry->get( node );
|
||||
auto fileValues = m_exteSmry->get( keyword );
|
||||
values->insert( values->begin(), fileValues.begin(), fileValues.end() );
|
||||
}
|
||||
|
||||
if ( m_eSmry )
|
||||
{
|
||||
auto fileValues = m_eSmry->get( keyword );
|
||||
values->insert( values->begin(), fileValues.begin(), fileValues.end() );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -168,14 +158,17 @@ bool RifOpmCommonEclipseSummary::values( const RifEclipseSummaryAddress& resultA
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::string RifOpmCommonEclipseSummary::unitName( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
if ( m_eSmry )
|
||||
auto it = m_adrToKeyword.find( resultAddress );
|
||||
if ( it != m_adrToKeyword.end() )
|
||||
{
|
||||
auto it = m_adrToSummaryNodeIndex.find( resultAddress );
|
||||
if ( it != m_adrToSummaryNodeIndex.end() )
|
||||
auto keyword = it->second;
|
||||
if ( m_exteSmry )
|
||||
{
|
||||
auto index = it->second;
|
||||
auto node = m_eSmry->summaryNodeList()[index];
|
||||
return m_eSmry->get_unit( node );
|
||||
return m_exteSmry->get_unit( keyword );
|
||||
}
|
||||
if ( m_eSmry )
|
||||
{
|
||||
return m_eSmry->get_unit( keyword );
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,20 +189,31 @@ RiaDefines::EclipseUnitSystem RifOpmCommonEclipseSummary::unitSystem() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifOpmCommonEclipseSummary::buildMetaData()
|
||||
{
|
||||
std::vector<Opm::time_point> dates;
|
||||
std::vector<std::string> keywords;
|
||||
|
||||
if ( m_exteSmry )
|
||||
{
|
||||
dates = m_exteSmry->dates();
|
||||
keywords = m_exteSmry->keywordList();
|
||||
}
|
||||
|
||||
if ( m_eSmry )
|
||||
{
|
||||
auto dates = m_eSmry->dates();
|
||||
for ( const auto& d : dates )
|
||||
{
|
||||
auto timeAsTimeT = std::chrono::system_clock::to_time_t( d );
|
||||
m_timeSteps.push_back( timeAsTimeT );
|
||||
}
|
||||
|
||||
auto [addresses, addressMap] = RifOpmCommonSummaryTools::buildMetaData( m_eSmry.get() );
|
||||
|
||||
m_allResultAddresses = addresses;
|
||||
m_adrToSummaryNodeIndex = addressMap;
|
||||
dates = m_eSmry->dates();
|
||||
keywords = m_eSmry->keywordList();
|
||||
}
|
||||
|
||||
for ( const auto& d : dates )
|
||||
{
|
||||
auto timeAsTimeT = std::chrono::system_clock::to_time_t( d );
|
||||
m_timeSteps.push_back( timeAsTimeT );
|
||||
}
|
||||
|
||||
auto [addresses, addressMap] = RifOpmCommonSummaryTools::buildMetaDataKeyword( keywords );
|
||||
|
||||
m_allResultAddresses = addresses;
|
||||
m_adrToKeyword = addressMap;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -263,9 +267,9 @@ void RifOpmCommonEclipseSummary::increaseLodFileCount()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RifOpmCommonEclipseSummary::extendedSummaryFilename( const QString& headerFileName)
|
||||
QString RifOpmCommonEclipseSummary::extendedSummaryFilename( const QString& headerFileName )
|
||||
{
|
||||
QString s(headerFileName);
|
||||
QString s( headerFileName );
|
||||
return s.replace( ".SMSPEC", ".ESMRY" );
|
||||
}
|
||||
|
||||
@ -379,3 +383,26 @@ std::pair<std::set<RifEclipseSummaryAddress>, std::map<RifEclipseSummaryAddress,
|
||||
|
||||
return { addresses, addressToNodeIndexMap };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<std::set<RifEclipseSummaryAddress>, std::map<RifEclipseSummaryAddress, std::string>>
|
||||
RifOpmCommonSummaryTools::buildMetaDataKeyword( const std::vector<std::string>& keywords )
|
||||
{
|
||||
std::set<RifEclipseSummaryAddress> addresses;
|
||||
std::map<RifEclipseSummaryAddress, std::string> addressToNodeIndexMap;
|
||||
|
||||
for ( auto keyword : keywords )
|
||||
{
|
||||
auto eclAdr = RifEclipseSummaryAddress::fromEclipseTextAddress( keyword );
|
||||
|
||||
if ( eclAdr.isValid() )
|
||||
{
|
||||
addresses.insert( eclAdr );
|
||||
addressToNodeIndexMap[eclAdr] = keyword;
|
||||
}
|
||||
}
|
||||
|
||||
return { addresses, addressToNodeIndexMap };
|
||||
}
|
||||
|
@ -52,6 +52,9 @@ public:
|
||||
|
||||
static std::pair<std::set<RifEclipseSummaryAddress>, std::map<RifEclipseSummaryAddress, size_t>>
|
||||
buildMetaData( const Opm::EclIO::ESmry* summaryFile );
|
||||
|
||||
static std::pair<std::set<RifEclipseSummaryAddress>, std::map<RifEclipseSummaryAddress, std::string>>
|
||||
buildMetaDataKeyword( const std::vector<std::string>& keywords );
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
@ -81,16 +84,16 @@ private:
|
||||
void buildMetaData();
|
||||
bool openESmryFile( const QString& headerFileName, bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger );
|
||||
|
||||
static void increaseLodFileCount();
|
||||
static QString extendedSummaryFilename(const QString& headerFileName);
|
||||
static void increaseLodFileCount();
|
||||
static QString extendedSummaryFilename( const QString& headerFileName );
|
||||
|
||||
private:
|
||||
std::unique_ptr<Opm::EclIO::ESmry> m_eSmry;
|
||||
std::unique_ptr<Opm::EclIO::ExtESmry> m_exteSmry;
|
||||
std::unique_ptr<Opm::EclIO::ESmry> m_eSmry;
|
||||
std::unique_ptr<Opm::EclIO::ExtESmry> m_exteSmry;
|
||||
|
||||
std::vector<std::string> m_eSmryKeywords;
|
||||
std::map<RifEclipseSummaryAddress, size_t> m_adrToSummaryNodeIndex;
|
||||
std::vector<time_t> m_timeSteps;
|
||||
std::vector<std::string> m_eSmryKeywords;
|
||||
std::map<RifEclipseSummaryAddress, std::string> m_adrToKeyword;
|
||||
std::vector<time_t> m_timeSteps;
|
||||
|
||||
static size_t sm_createdLodFileCount;
|
||||
|
||||
|
@ -79,6 +79,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigSurfaceResampler-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigSurfaceStatisticsCalculator-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/StructGridInterface-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/opm-summary-Test.cpp
|
||||
)
|
||||
|
||||
if(RESINSIGHT_ENABLE_GRPC)
|
||||
|
53
ApplicationLibCode/UnitTests/opm-summary-Test.cpp
Normal file
53
ApplicationLibCode/UnitTests/opm-summary-Test.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "RiaTestDataDirectory.h"
|
||||
#include "RifOpmCommonSummary.h"
|
||||
|
||||
#include "opm/io/eclipse/ESmry.hpp"
|
||||
#include "opm/io/eclipse/ExtESmry.hpp"
|
||||
|
||||
static const QString H5_TEST_DATA_DIRECTORY = QString( "%1/h5-file/" ).arg( TEST_DATA_DIR );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( DISABLED_OpmSummaryTests, ReadOpmSummaryDataListContent )
|
||||
{
|
||||
std::vector<std::string> esmryKeywords;
|
||||
{
|
||||
QString filePath = H5_TEST_DATA_DIRECTORY + "NORNE_ATW2013_RFTPLT_V2.SMSPEC";
|
||||
|
||||
Opm::EclIO::ESmry eSmry( filePath.toStdString() );
|
||||
|
||||
esmryKeywords = eSmry.keywordList();
|
||||
eSmry.make_esmry_file();
|
||||
}
|
||||
|
||||
std::vector<std::string> extEsmryKeywords;
|
||||
{
|
||||
QString filePath = H5_TEST_DATA_DIRECTORY + "NORNE_ATW2013_RFTPLT_V2.ESMRY";
|
||||
|
||||
Opm::EclIO::ExtESmry extEsmry( filePath.toStdString() );
|
||||
|
||||
extEsmryKeywords = extEsmry.keywordList();
|
||||
}
|
||||
|
||||
EXPECT_EQ( esmryKeywords.size(), extEsmryKeywords.size() );
|
||||
for ( size_t i = 0; i < esmryKeywords.size(); i++ )
|
||||
{
|
||||
auto s1 = esmryKeywords[i];
|
||||
auto s2 = extEsmryKeywords[i];
|
||||
EXPECT_STREQ( s1.c_str(), s2.c_str() );
|
||||
|
||||
RifEclipseSummaryAddress eclAdr = RifEclipseSummaryAddress::fromEclipseTextAddress( s1 );
|
||||
EXPECT_TRUE( eclAdr.isValid() );
|
||||
}
|
||||
|
||||
/*
|
||||
auto keywords = eSmry.keywordList();
|
||||
for ( auto k : keywords )
|
||||
{
|
||||
std::cout << k << "\n";
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
Reference in New Issue
Block a user