mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-20 11:48:35 -06:00
#5694 Summary Address : Add difference if both native and history is present
This commit is contained in:
parent
5ee182f7db
commit
8e7d5d29b3
@ -17,8 +17,11 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "RifReaderEclipseSummary.h"
|
#include "RifReaderEclipseSummary.h"
|
||||||
|
|
||||||
#include "RiaFilePathTools.h"
|
#include "RiaFilePathTools.h"
|
||||||
|
#include "RiaStdStringTools.h"
|
||||||
#include "RiaStringEncodingTools.h"
|
#include "RiaStringEncodingTools.h"
|
||||||
|
|
||||||
#include "RifEclipseSummaryTools.h"
|
#include "RifEclipseSummaryTools.h"
|
||||||
#include "RifReaderEclipseOutput.h"
|
#include "RifReaderEclipseOutput.h"
|
||||||
|
|
||||||
@ -425,10 +428,6 @@ bool RifReaderEclipseSummary::values( const RifEclipseSummaryAddress& resultAddr
|
|||||||
{
|
{
|
||||||
assert( m_ecl_sum != nullptr );
|
assert( m_ecl_sum != nullptr );
|
||||||
|
|
||||||
int variableIndex = indexFromAddress( resultAddress );
|
|
||||||
|
|
||||||
if ( variableIndex < 0 ) return false;
|
|
||||||
|
|
||||||
values->clear();
|
values->clear();
|
||||||
values->reserve( timeStepCount() );
|
values->reserve( timeStepCount() );
|
||||||
|
|
||||||
@ -439,6 +438,39 @@ bool RifReaderEclipseSummary::values( const RifEclipseSummaryAddress& resultAddr
|
|||||||
}
|
}
|
||||||
else if ( m_ecl_SmSpec )
|
else if ( m_ecl_SmSpec )
|
||||||
{
|
{
|
||||||
|
if ( m_differenceAddresses.count( resultAddress ) )
|
||||||
|
{
|
||||||
|
std::string quantityName = resultAddress.quantityName();
|
||||||
|
auto historyQuantity = quantityName.substr( 0, quantityName.size() - differenceIdentifier().size() );
|
||||||
|
|
||||||
|
RifEclipseSummaryAddress nativeAdrNoHistory = resultAddress;
|
||||||
|
nativeAdrNoHistory.setQuantityName( historyQuantity );
|
||||||
|
auto quantityNoHistory = quantityName.substr( 0, historyQuantity.size() - 1 );
|
||||||
|
|
||||||
|
RifEclipseSummaryAddress nativeAdrHistory = resultAddress;
|
||||||
|
nativeAdrHistory.setQuantityName( quantityNoHistory );
|
||||||
|
|
||||||
|
std::vector<double> nativeValues;
|
||||||
|
std::vector<double> historyValues;
|
||||||
|
|
||||||
|
if ( !this->values( nativeAdrHistory, &nativeValues ) ) return false;
|
||||||
|
if ( !this->values( nativeAdrNoHistory, &historyValues ) ) return false;
|
||||||
|
|
||||||
|
if ( nativeValues.size() != historyValues.size() ) return false;
|
||||||
|
|
||||||
|
for ( size_t i = 0; i < nativeValues.size(); i++ )
|
||||||
|
{
|
||||||
|
double diff = nativeValues[i] - historyValues[i];
|
||||||
|
values->push_back( diff );
|
||||||
|
m_valuesCache->insertValues( resultAddress, *values );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int variableIndex = indexFromAddress( resultAddress );
|
||||||
|
if ( variableIndex < 0 ) return false;
|
||||||
|
|
||||||
const ecl::smspec_node& ertSumVarNode = ecl_smspec_iget_node_w_node_index( m_ecl_SmSpec, variableIndex );
|
const ecl::smspec_node& ertSumVarNode = ecl_smspec_iget_node_w_node_index( m_ecl_SmSpec, variableIndex );
|
||||||
int paramsIndex = ertSumVarNode.get_params_index();
|
int paramsIndex = ertSumVarNode.get_params_index();
|
||||||
|
|
||||||
@ -513,6 +545,55 @@ void RifReaderEclipseSummary::buildMetaData()
|
|||||||
m_resultAddressToErtNodeIdx[addr] = i;
|
m_resultAddressToErtNodeIdx[addr] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool addDifferenceVectors = true;
|
||||||
|
if ( addDifferenceVectors )
|
||||||
|
{
|
||||||
|
const std::string historyIdentifier( "H" );
|
||||||
|
|
||||||
|
for ( const auto& adr : m_allResultAddresses )
|
||||||
|
{
|
||||||
|
RifEclipseSummaryAddress adrWithHistory;
|
||||||
|
RifEclipseSummaryAddress adrWithoutHistory;
|
||||||
|
|
||||||
|
{
|
||||||
|
std::string s = adr.quantityName();
|
||||||
|
if ( RiaStdStringTools::endsWith( s, historyIdentifier ) )
|
||||||
|
{
|
||||||
|
RifEclipseSummaryAddress candidate = adr;
|
||||||
|
|
||||||
|
std::string quantityNoHistory = s.substr( 0, s.size() - 1 );
|
||||||
|
candidate.setQuantityName( quantityNoHistory );
|
||||||
|
if ( m_allResultAddresses.count( candidate ) )
|
||||||
|
{
|
||||||
|
adrWithHistory = adr;
|
||||||
|
adrWithoutHistory = candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RifEclipseSummaryAddress candidate = adr;
|
||||||
|
candidate.setQuantityName( s + historyIdentifier );
|
||||||
|
if ( m_allResultAddresses.count( candidate ) )
|
||||||
|
{
|
||||||
|
adrWithHistory = candidate;
|
||||||
|
adrWithoutHistory = adr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( adrWithoutHistory.isValid() && adrWithHistory.isValid() )
|
||||||
|
{
|
||||||
|
RifEclipseSummaryAddress candidate = adr;
|
||||||
|
|
||||||
|
std::string s = candidate.quantityName() + differenceIdentifier();
|
||||||
|
candidate.setQuantityName( s );
|
||||||
|
|
||||||
|
m_allResultAddresses.insert( candidate );
|
||||||
|
m_differenceAddresses.insert( candidate );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -86,6 +86,8 @@ private:
|
|||||||
void buildMetaData();
|
void buildMetaData();
|
||||||
RifRestartFileInfo getRestartFile( const QString& headerFileName );
|
RifRestartFileInfo getRestartFile( const QString& headerFileName );
|
||||||
|
|
||||||
|
static std::string differenceIdentifier() { return "_DIFF"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Taken from ecl_sum.h
|
// Taken from ecl_sum.h
|
||||||
typedef struct ecl_sum_struct ecl_sum_type;
|
typedef struct ecl_sum_struct ecl_sum_type;
|
||||||
@ -101,6 +103,8 @@ private:
|
|||||||
|
|
||||||
QStringList m_warnings;
|
QStringList m_warnings;
|
||||||
|
|
||||||
|
std::set<RifEclipseSummaryAddress> m_differenceAddresses;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
//
|
//
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
Loading…
Reference in New Issue
Block a user