diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 5d7bfa9137..6274686080 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -774,33 +774,18 @@ void RicWellPathExportCompletionDataFeatureImpl::exportWelspeclToFile( RimEclips for ( const auto& completion : completionsForLgr.second ) { const auto wellPath = RicWellPathExportCompletionsFileTools::findWellPathFromExportName( completion.wellName() ); + if ( !wellPath ) continue; wellPathToLgrNameMap[wellPath].insert( completionsForLgr.first ); } } - for ( const auto& wellPathsForLgr : wellPathToLgrNameMap ) + // See similar logic in RiaGrpcWellPathService::GetCompletionData() + + for ( const auto& [wellPath, gridNames] : wellPathToLgrNameMap ) { - const RimWellPath* wellPath = wellPathsForLgr.first; - - std::tuple itemWithLowestMD = std::make_tuple( std::numeric_limits::max(), cvf::Vec2i(), "" ); - - // Find first LGR-intersection along the well path - - for ( const auto& lgrName : wellPathsForLgr.second ) + for ( const auto& lgrName : gridNames ) { - auto ijIntersection = wellPathUpperGridIntersectionIJ( gridCase, wellPath, lgrName ); - if ( ijIntersection.first < std::get<0>( itemWithLowestMD ) ) - { - itemWithLowestMD = std::make_tuple( ijIntersection.first, ijIntersection.second, lgrName ); - } - } - - { - double measuredDepth = 0.0; - cvf::Vec2i ijIntersection; - QString lgrName; - - std::tie( measuredDepth, ijIntersection, lgrName ) = itemWithLowestMD; + const auto& [measuredDepth, ijIntersection] = wellPathUpperGridIntersectionIJ( gridCase, wellPath, lgrName ); auto completionSettings = wellPath->completionSettings(); diff --git a/GrpcInterface/RiaGrpcWellPathService.cpp b/GrpcInterface/RiaGrpcWellPathService.cpp index 52a107f245..2cf40524ba 100644 --- a/GrpcInterface/RiaGrpcWellPathService.cpp +++ b/GrpcInterface/RiaGrpcWellPathService.cpp @@ -45,7 +45,7 @@ namespace internal //-------------------------------------------------------------------------------------------------- void populateReply( RimEclipseCase* eclipseCase, RimWellPath* wellPath, ::rips::SimulatorTableData* reply ) { - std::set gridNames; + std::set gridNamesWithCompletions; auto compdata = RicWellPathExportCompletionDataFeatureImpl::completionDataForWellPath( wellPath, eclipseCase ); for ( const auto& cd : compdata ) { @@ -53,7 +53,7 @@ void populateReply( RimEclipseCase* eclipseCase, RimWellPath* wellPath, ::rips:: RiaWellPathDataToGrpcConverter::copyCompdatToGrpc( cd, grpcData ); auto completionCell = cd.completionDataGridCell(); - gridNames.insert( completionCell.lgrName() ); + gridNamesWithCompletions.insert( completionCell.lgrName() ); const auto wpimult = cd.wpimult(); if ( wpimult != 0.0 && !RigCompletionData::isDefaultValue( wpimult ) ) @@ -71,31 +71,22 @@ void populateReply( RimEclipseCase* eclipseCase, RimWellPath* wellPath, ::rips:: } // See RicWellPathExportCompletionDataFeatureImpl::exportWelspeclToFile - // Find the grid with the uppermost intersection along the well path - std::tuple itemWithLowestMD = - std::make_tuple( std::numeric_limits::max(), cvf::Vec2i(), "" ); - - for ( const auto& gridName : gridNames ) + for ( const auto& gridName : gridNamesWithCompletions ) { - auto candidate = + auto upperGridIntersection = RicWellPathExportCompletionDataFeatureImpl::wellPathUpperGridIntersectionIJ( eclipseCase, wellPath, gridName ); - if ( candidate.first < std::get<0>( itemWithLowestMD ) ) - { - itemWithLowestMD = std::make_tuple( candidate.first, candidate.second, gridName ); - } + + auto compSettings = wellPath->completionSettings(); + cvf::Vec2i ijIntersection = std::get<1>( upperGridIntersection ); + + SimulatorWelspecsEntry* grpcData = reply->add_welspecs(); + RiaWellPathDataToGrpcConverter::copyWelspecsToGrpc( compSettings, + grpcData, + ijIntersection.x(), + ijIntersection.y(), + gridName.toStdString() ); } - auto compSettings = wellPath->completionSettings(); - cvf::Vec2i ijIntersection = std::get<1>( itemWithLowestMD ); - QString lgrName = std::get<2>( itemWithLowestMD ); - - SimulatorWelspecsEntry* grpcData = reply->add_welspecs(); - RiaWellPathDataToGrpcConverter::copyWelspecsToGrpc( compSettings, - grpcData, - ijIntersection.x(), - ijIntersection.y(), - lgrName.toStdString() ); - // Multisegment wells int timeStep = 0;