mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
#7912 Summary Data Import : Map from eclAdr to keyword
This commit is contained in:
@@ -93,7 +93,7 @@ bool RifOpmCommonEclipseSummary::open( const QString& headerFileName,
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto temporarySummaryFile =
|
auto temporarySummaryFile =
|
||||||
std::make_unique<Opm::EclIO::ESmry>(headerFileName.toStdString(), includeRestartFiles );
|
std::make_unique<Opm::EclIO::ESmry>( headerFileName.toStdString(), includeRestartFiles );
|
||||||
|
|
||||||
temporarySummaryFile->make_esmry_file();
|
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
|
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 );
|
auto keyword = it->second;
|
||||||
if ( it != m_adrToSummaryNodeIndex.end() )
|
if ( m_exteSmry )
|
||||||
{
|
{
|
||||||
// auto index = it->second;
|
auto fileValues = m_exteSmry->get( keyword );
|
||||||
// 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 );
|
|
||||||
values->insert( values->begin(), fileValues.begin(), fileValues.end() );
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,14 +158,17 @@ bool RifOpmCommonEclipseSummary::values( const RifEclipseSummaryAddress& resultA
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
std::string RifOpmCommonEclipseSummary::unitName( const RifEclipseSummaryAddress& resultAddress ) const
|
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 );
|
auto keyword = it->second;
|
||||||
if ( it != m_adrToSummaryNodeIndex.end() )
|
if ( m_exteSmry )
|
||||||
{
|
{
|
||||||
auto index = it->second;
|
return m_exteSmry->get_unit( keyword );
|
||||||
auto node = m_eSmry->summaryNodeList()[index];
|
}
|
||||||
return m_eSmry->get_unit( node );
|
if ( m_eSmry )
|
||||||
|
{
|
||||||
|
return m_eSmry->get_unit( keyword );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,20 +189,31 @@ RiaDefines::EclipseUnitSystem RifOpmCommonEclipseSummary::unitSystem() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RifOpmCommonEclipseSummary::buildMetaData()
|
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 )
|
if ( m_eSmry )
|
||||||
{
|
{
|
||||||
auto dates = m_eSmry->dates();
|
dates = m_eSmry->dates();
|
||||||
for ( const auto& d : dates )
|
keywords = m_eSmry->keywordList();
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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" );
|
return s.replace( ".SMSPEC", ".ESMRY" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,3 +383,26 @@ std::pair<std::set<RifEclipseSummaryAddress>, std::map<RifEclipseSummaryAddress,
|
|||||||
|
|
||||||
return { addresses, addressToNodeIndexMap };
|
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>>
|
static std::pair<std::set<RifEclipseSummaryAddress>, std::map<RifEclipseSummaryAddress, size_t>>
|
||||||
buildMetaData( const Opm::EclIO::ESmry* summaryFile );
|
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();
|
void buildMetaData();
|
||||||
bool openESmryFile( const QString& headerFileName, bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger );
|
bool openESmryFile( const QString& headerFileName, bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger );
|
||||||
|
|
||||||
static void increaseLodFileCount();
|
static void increaseLodFileCount();
|
||||||
static QString extendedSummaryFilename(const QString& headerFileName);
|
static QString extendedSummaryFilename( const QString& headerFileName );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Opm::EclIO::ESmry> m_eSmry;
|
std::unique_ptr<Opm::EclIO::ESmry> m_eSmry;
|
||||||
std::unique_ptr<Opm::EclIO::ExtESmry> m_exteSmry;
|
std::unique_ptr<Opm::EclIO::ExtESmry> m_exteSmry;
|
||||||
|
|
||||||
std::vector<std::string> m_eSmryKeywords;
|
std::vector<std::string> m_eSmryKeywords;
|
||||||
std::map<RifEclipseSummaryAddress, size_t> m_adrToSummaryNodeIndex;
|
std::map<RifEclipseSummaryAddress, std::string> m_adrToKeyword;
|
||||||
std::vector<time_t> m_timeSteps;
|
std::vector<time_t> m_timeSteps;
|
||||||
|
|
||||||
static size_t sm_createdLodFileCount;
|
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}/RigSurfaceResampler-Test.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RigSurfaceStatisticsCalculator-Test.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RigSurfaceStatisticsCalculator-Test.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/StructGridInterface-Test.cpp
|
${CMAKE_CURRENT_LIST_DIR}/StructGridInterface-Test.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/opm-summary-Test.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(RESINSIGHT_ENABLE_GRPC)
|
if(RESINSIGHT_ENABLE_GRPC)
|
||||||
|
|||||||
@@ -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";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user