From 6fd424ae854d78afffd4200eed2ac32114f6264a Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 6 Dec 2024 15:37:19 +0100 Subject: [PATCH] Produce all results. --- .../Well/RigWellTargetCandidatesGenerator.cpp | 117 ++++++++++++------ 1 file changed, 80 insertions(+), 37 deletions(-) diff --git a/ApplicationLibCode/ReservoirDataModel/Well/RigWellTargetCandidatesGenerator.cpp b/ApplicationLibCode/ReservoirDataModel/Well/RigWellTargetCandidatesGenerator.cpp index 112162fd94..a62a12bb6d 100644 --- a/ApplicationLibCode/ReservoirDataModel/Well/RigWellTargetCandidatesGenerator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/Well/RigWellTargetCandidatesGenerator.cpp @@ -190,8 +190,20 @@ void RigWellTargetCandidatesGenerator::generateCandidates( RimEclipseCase* RiaLogging::info( QString( "Average Permeability: %1" ).arg( s.permeability ) ); RiaLogging::info( QString( "Average Pressure: %1" ).arg( s.pressure ) ); - QString clusterPorvSoil = "CLUSTER_TOTAL_PORV_SOIL"; + QString clusterPorvSoil = "TOTAL_PORV_SOIL"; createResultVector( *eclipseCase, clusterPorvSoil, clusters, s.totalPorvSoil ); + + QString clusterPorvSgas = "TOTAL_PORV_SGAS"; + createResultVector( *eclipseCase, clusterPorvSgas, clusters, s.totalPorvSgas ); + + QString clusterPorvSoilAndSgas = "TOTAL_PORV_SOIL_SGAS"; + createResultVector( *eclipseCase, clusterPorvSoilAndSgas, clusters, s.totalPorvSoilAndSgas ); + + QString clusterFipOil = "TOTAL_FIPOIL"; + createResultVector( *eclipseCase, clusterFipOil, clusters, s.totalFipOil ); + + QString clusterFipGas = "TOTAL_FIPGAS"; + createResultVector( *eclipseCase, clusterFipGas, clusters, s.totalFipGas ); } } @@ -692,7 +704,12 @@ void RigWellTargetCandidatesGenerator::generateEnsembleCandidates( RimEclipseCas std::vector occupancy( targetNumActiveCells, 0 ); - std::vector> porvSoilSamples; + std::map>> porvSoilSamples; + porvSoilSamples["TOTAL_PORV_SOIL"] = {}; + porvSoilSamples["TOTAL_PORV_SGAS"] = {}; + porvSoilSamples["TOTAL_PORV_SOIL_SGAS"] = {}; + porvSoilSamples["TOTAL_FIPOIL"] = {}; + porvSoilSamples["TOTAL_FIPGAS"] = {}; for ( auto eclipseCase : ensemble.cases() ) { @@ -706,12 +723,21 @@ void RigWellTargetCandidatesGenerator::generateEnsembleCandidates( RimEclipseCas resultsData->ensureKnownResultLoaded( clustersNumAddress ); const std::vector& clusterNum = resultsData->cellScalarResults( clustersNumAddress, 0 ); - QString clusterPorvSoil = "CLUSTER_TOTAL_PORV_SOIL"; - RigEclipseResultAddress clusterPorvSoilAddress( RiaDefines::ResultCatType::GENERATED, clusterPorvSoil ); - resultsData->ensureKnownResultLoaded( clusterPorvSoilAddress ); - const std::vector& porvSoil = resultsData->cellScalarResults( clusterPorvSoilAddress, 0 ); + std::map*> porvSoil; - std::vector totalPorvSoil( targetNumActiveCells, std::numeric_limits::infinity() ); + for ( auto [resultName, vec] : porvSoilSamples ) + { + RigEclipseResultAddress clusterPorvSoilAddress( RiaDefines::ResultCatType::GENERATED, resultName ); + resultsData->ensureKnownResultLoaded( clusterPorvSoilAddress ); + const std::vector& resultVector = resultsData->cellScalarResults( clusterPorvSoilAddress, 0 ); + porvSoil[resultName] = &resultVector; + } + + std::map> totalPorvSoil; + for ( auto [resultName, vec] : porvSoilSamples ) + { + totalPorvSoil[resultName] = std::vector( targetNumActiveCells, std::numeric_limits::infinity() ); + } for ( size_t targetCellIdx = 0; targetCellIdx < targetNumReservoirCells; targetCellIdx++ ) { @@ -727,43 +753,60 @@ void RigWellTargetCandidatesGenerator::generateEnsembleCandidates( RimEclipseCas if ( !std::isinf( clusterNum[resultIndex] ) && clusterNum[resultIndex] > 0 ) { occupancy[targetResultIndex]++; - totalPorvSoil[targetResultIndex] = porvSoil[resultIndex]; + for ( auto [resultName, vec] : porvSoilSamples ) + { + totalPorvSoil[resultName][targetResultIndex] = porvSoil[resultName]->at( resultIndex ); + } } } } - porvSoilSamples.push_back( totalPorvSoil ); + for ( auto [resultName, vec] : porvSoilSamples ) + { + porvSoilSamples[resultName].push_back( totalPorvSoil[resultName] ); + } } - int nCells = static_cast( targetNumActiveCells ); - std::vector p10Results( nCells, std::numeric_limits::infinity() ); - std::vector p50Results( nCells, std::numeric_limits::infinity() ); - std::vector p90Results( nCells, std::numeric_limits::infinity() ); - std::vector meanResults( nCells, std::numeric_limits::infinity() ); - std::vector minResults( nCells, std::numeric_limits::infinity() ); - std::vector maxResults( nCells, std::numeric_limits::infinity() ); + createResultVector( targetCase, "OCCUPANCY", occupancy ); -#pragma omp parallel for - for ( int i = 0; i < nCells; i++ ) + for ( auto [resultName, vec] : porvSoilSamples ) { - size_t numSamples = porvSoilSamples.size(); - std::vector samples( numSamples, 0.0 ); - for ( size_t s = 0; s < numSamples; s++ ) - samples[s] = porvSoilSamples[s][i]; - - double p10, p50, p90, mean; - RigStatisticsMath::calculateStatisticsCurves( samples, &p10, &p50, &p90, &mean, RigStatisticsMath::PercentileStyle::SWITCHED ); - - p10Results[i] = p10; - p50Results[i] = p50; - p90Results[i] = p90; - printf( "P90[%d] => %f\n", i, p90 ); - meanResults[i] = mean; - - minResults[i] = RiaStatisticsTools::minimumValue( samples ); - maxResults[i] = RiaStatisticsTools::maximumValue( samples ); - } + int nCells = static_cast( targetNumActiveCells ); + std::vector p10Results( nCells, std::numeric_limits::infinity() ); + std::vector p50Results( nCells, std::numeric_limits::infinity() ); + std::vector p90Results( nCells, std::numeric_limits::infinity() ); + std::vector meanResults( nCells, std::numeric_limits::infinity() ); + std::vector minResults( nCells, std::numeric_limits::infinity() ); + std::vector maxResults( nCells, std::numeric_limits::infinity() ); - createResultVector( targetCase, "OCCUPANCY", occupancy ); - createResultVector( targetCase, "CLUSTER_TOTAL_PORV_SOIL_P90", p90Results ); +#pragma omp parallel for + for ( int i = 0; i < nCells; i++ ) + { + size_t numSamples = vec.size(); + std::vector samples( numSamples, 0.0 ); + for ( size_t s = 0; s < numSamples; s++ ) + samples[s] = vec[s][i]; + + double p10, p50, p90, mean; + RigStatisticsMath::calculateStatisticsCurves( samples, &p10, &p50, &p90, &mean, RigStatisticsMath::PercentileStyle::SWITCHED ); + + if ( RiaStatisticsTools::isValidNumber( p10 ) ) p10Results[i] = p10; + if ( RiaStatisticsTools::isValidNumber( p50 ) ) p50Results[i] = p50; + if ( RiaStatisticsTools::isValidNumber( p90 ) ) p90Results[i] = p90; + if ( RiaStatisticsTools::isValidNumber( mean ) ) meanResults[i] = mean; + + double minValue = RiaStatisticsTools::minimumValue( samples ); + if ( RiaStatisticsTools::isValidNumber( minValue ) && minValue < std::numeric_limits::max() ) minResults[i] = minValue; + + double maxValue = RiaStatisticsTools::maximumValue( samples ); + if ( RiaStatisticsTools::isValidNumber( maxValue ) && maxValue > -std::numeric_limits::max() ) maxResults[i] = maxValue; + } + + createResultVector( targetCase, "ENSEMBLE_" + resultName + "_P10", p10Results ); + createResultVector( targetCase, "ENSEMBLE_" + resultName + "_P50", p50Results ); + createResultVector( targetCase, "ENSEMBLE_" + resultName + "_P90", p90Results ); + createResultVector( targetCase, "ENSEMBLE_" + resultName + "_MEAN", meanResults ); + createResultVector( targetCase, "ENSEMBLE_" + resultName + "_MIN", minResults ); + createResultVector( targetCase, "ENSEMBLE_" + resultName + "_MAX", maxResults ); + } }