Do not clear generated results during statistics computation

This commit is contained in:
Magne Sjaastad 2023-07-04 16:56:02 +02:00 committed by GitHub
parent 93c943543b
commit 09b8bfdc06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 41 deletions

View File

@ -108,44 +108,7 @@ void RimEclipseStatisticsCaseEvaluator::evaluateForResults( const QList<ResSpec>
CVF_ASSERT( m_destinationCase );
// First build the destination result data structures to receive the statistics
for ( int i = 0; i < resultSpecification.size(); i++ )
{
RiaDefines::PorosityModelType poroModel = resultSpecification[i].m_poroModel;
RiaDefines::ResultCatType resultType = resultSpecification[i].m_resType;
QString resultName = resultSpecification[i].m_resVarName;
size_t activeCellCount = m_destinationCase->activeCellInfo( poroModel )->reservoirActiveCellCount();
RigCaseCellResultsData* destCellResultsData = m_destinationCase->results( poroModel );
// Placeholder data used to be created here,
// this is now moved to RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo()
// Create new result data structures to contain the statistical values
std::vector<QString> statisticalResultNames;
statisticalResultNames.push_back( createResultNameMin( resultName ) );
statisticalResultNames.push_back( createResultNameMax( resultName ) );
statisticalResultNames.push_back( createResultNameSum( resultName ) );
statisticalResultNames.push_back( createResultNameMean( resultName ) );
statisticalResultNames.push_back( createResultNameDev( resultName ) );
statisticalResultNames.push_back( createResultNameRange( resultName ) );
if ( m_statisticsConfig.m_calculatePercentiles )
{
statisticalResultNames.push_back( createResultNamePVal( resultName, m_statisticsConfig.m_pMinPos ) );
statisticalResultNames.push_back( createResultNamePVal( resultName, m_statisticsConfig.m_pMidPos ) );
statisticalResultNames.push_back( createResultNamePVal( resultName, m_statisticsConfig.m_pMaxPos ) );
}
if ( activeCellCount > 0 )
{
for ( size_t j = 0; j < statisticalResultNames.size(); ++j )
{
addNamedResult( destCellResultsData, resultType, statisticalResultNames[j], activeCellCount );
}
}
}
addNamedResults( resultSpecification );
// Start the loop that calculates the statistics
@ -362,6 +325,49 @@ void RimEclipseStatisticsCaseEvaluator::evaluateForResults( const QList<ResSpec>
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseStatisticsCaseEvaluator::addNamedResults( const QList<ResSpec>& resultSpecification )
{
for ( int i = 0; i < resultSpecification.size(); i++ )
{
RiaDefines::PorosityModelType poroModel = resultSpecification[i].m_poroModel;
RiaDefines::ResultCatType resultType = resultSpecification[i].m_resType;
QString resultName = resultSpecification[i].m_resVarName;
size_t activeCellCount = m_destinationCase->activeCellInfo( poroModel )->reservoirActiveCellCount();
if ( activeCellCount == 0 ) continue;
RigCaseCellResultsData* destCellResultsData = m_destinationCase->results( poroModel );
// Placeholder data used to be created here,
// this is now moved to RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo()
// Create new result data structures to contain the statistical values
std::vector<QString> statisticalResultNames;
statisticalResultNames.push_back( createResultNameMin( resultName ) );
statisticalResultNames.push_back( createResultNameMax( resultName ) );
statisticalResultNames.push_back( createResultNameSum( resultName ) );
statisticalResultNames.push_back( createResultNameMean( resultName ) );
statisticalResultNames.push_back( createResultNameDev( resultName ) );
statisticalResultNames.push_back( createResultNameRange( resultName ) );
if ( m_statisticsConfig.m_calculatePercentiles )
{
statisticalResultNames.push_back( createResultNamePVal( resultName, m_statisticsConfig.m_pMinPos ) );
statisticalResultNames.push_back( createResultNamePVal( resultName, m_statisticsConfig.m_pMidPos ) );
statisticalResultNames.push_back( createResultNamePVal( resultName, m_statisticsConfig.m_pMaxPos ) );
}
for ( size_t j = 0; j < statisticalResultNames.size(); ++j )
{
addNamedResult( destCellResultsData, resultType, statisticalResultNames[j], activeCellCount );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -83,11 +83,11 @@ public:
void evaluateForResults( const QList<ResSpec>& resultSpecification );
private:
void addNamedResults( const QList<ResSpec>& resultSpecification );
void addNamedResult( RigCaseCellResultsData* cellResults,
RiaDefines::ResultCatType resultType,
const QString& resultName,
size_t activeCellCount );
void buildSourceMetaData( RiaDefines::PorosityModelType poroModel, RiaDefines::ResultCatType resultType, const QString& resultName );
enum StatisticsParamType
{

View File

@ -703,12 +703,19 @@ void RigCaseCellResultsData::freeAllocatedResultsData()
{
for ( size_t resultIdx = 0; resultIdx < m_cellScalarResults.size(); ++resultIdx )
{
for ( size_t tsIdx = 0; tsIdx < m_cellScalarResults[resultIdx].size(); ++tsIdx )
if ( resultIdx < m_resultInfos.size() &&
m_resultInfos[resultIdx].eclipseResultAddress().resultCatType() == RiaDefines::ResultCatType::GENERATED )
{
// Not possible to recreate generated results, keep them
continue;
}
for ( auto& tsIdx : m_cellScalarResults[resultIdx] )
{
// Using swap with an empty vector as that is the safest way to really get rid of the allocated data in a
// vector
std::vector<double> empty;
m_cellScalarResults[resultIdx][tsIdx].swap( empty );
tsIdx.swap( empty );
}
}
}