From 20db9141f2049dc7215d068dea7dce834dbf38fb Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 4 Oct 2024 13:24:53 +0200 Subject: [PATCH] WIP: create occupancy grid --- .../Well/RigWellTargetCandidatesGenerator.cpp | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ApplicationLibCode/ReservoirDataModel/Well/RigWellTargetCandidatesGenerator.cpp b/ApplicationLibCode/ReservoirDataModel/Well/RigWellTargetCandidatesGenerator.cpp index 72fee8b3f3..b0173a0055 100644 --- a/ApplicationLibCode/ReservoirDataModel/Well/RigWellTargetCandidatesGenerator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/Well/RigWellTargetCandidatesGenerator.cpp @@ -614,6 +614,8 @@ void RigWellTargetCandidatesGenerator::generateEnsembleCandidates( RimEclipseCas VolumeResultType volumeResultType, const ClusteringLimits& limits ) { + RiaLogging::debug( "Generating ensemble statistics" ); + for ( auto eclipseCase : ensemble.cases() ) { generateCandidates( eclipseCase, timeStepIdx, volumeType, volumesType, volumeResultType, limits ); @@ -624,32 +626,32 @@ void RigWellTargetCandidatesGenerator::generateEnsembleCandidates( RimEclipseCas const size_t targetNumReservoirCells = targetActiveCellInfo->reservoirCellCount(); const size_t targetNumActiveCells = targetActiveCellInfo->reservoirActiveCellCount(); - const int numGrids = ensemble.cases().size(); - std::vector occupancy( targetNumActiveCells, 0 ); - std::vector pressure( numGrids, std::numeric_limits::infinity() ); + std::vector occupancy( targetNumActiveCells, 0 ); for ( auto eclipseCase : ensemble.cases() ) { RigCaseCellResultsData* resultsData = eclipseCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL ); const RigMainGrid* mainGrid = eclipseCase->mainGrid(); const RigActiveCellInfo* activeCellInfo = resultsData->activeCellInfo(); - RigEclipseResultAddress pressureAddress( RiaDefines::ResultCatType::GENERATED, "CLUSTER_NUM" ); + RigEclipseResultAddress pressureAddress( RiaDefines::ResultCatType::GENERATED, "CLUSTERS_NUM" ); resultsData->ensureKnownResultLoaded( pressureAddress ); - const std::vector& clusterNum = resultsData->cellScalarResults( pressureAddress, timeStepIdx ); + const std::vector& clusterNum = resultsData->cellScalarResults( pressureAddress, 0 ); for ( size_t targetCellIdx = 0; targetCellIdx < targetNumReservoirCells; targetCellIdx++ ) { const RigCell& nativeCell = targetCase.mainGrid()->globalCellArray()[targetCellIdx]; cvf::Vec3d cellCenter = nativeCell.center(); + size_t targetResultIndex = targetActiveCellInfo->cellResultIndex( targetCellIdx ); + size_t cellIdx = mainGrid->findReservoirCellIndexFromPoint( cellCenter ); - if ( cellIdx != cvf::UNDEFINED_SIZE_T && activeCellInfo->isActive( cellIdx ) ) + if ( cellIdx != cvf::UNDEFINED_SIZE_T && activeCellInfo->isActive( cellIdx ) && targetResultIndex != cvf::UNDEFINED_SIZE_T ) { - size_t resultIndex = targetResultsData->activeCellInfo()->cellResultIndex( cellIdx ); - if ( clusterNum[resultIndex] > 0 ) + size_t resultIndex = resultsData->activeCellInfo()->cellResultIndex( cellIdx ); + if ( !std::isinf( clusterNum[resultIndex] ) && clusterNum[resultIndex] > 0 ) { - occupancy[resultIndex]++; + occupancy[targetResultIndex]++; } } }