From f5fb6bc047b9ad2f1f13e1ceee4e1843615f4aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 10 Nov 2020 11:15:17 +0100 Subject: [PATCH] Summary: Don't Index Out-of-Bounds During Node Configuration The 'schedule_wells' vector is guaranteed to be empty when we're configuring the set of summary vectors to report. Don't blindly access the .front() element. --- src/opm/output/eclipse/Summary.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/opm/output/eclipse/Summary.cpp b/src/opm/output/eclipse/Summary.cpp index 4995f556b..ff301b583 100644 --- a/src/opm/output/eclipse/Summary.cpp +++ b/src/opm/output/eclipse/Summary.cpp @@ -528,7 +528,13 @@ inline quantity rate( const fn_args& args ) { template< rt phase, bool injection = true > inline quantity ratel( const fn_args& args ) { - const quantity zero = { 0, rate_unit< phase >() }; + const auto unit = ((phase == rt::polymer) || (phase == rt::brine)) + ? measure::mass_rate : rate_unit(); + + const quantity zero = { 0.0, unit }; + + if (args.schedule_wells.empty()) + return zero; const auto& well = args.schedule_wells.front(); const auto& name = well.name(); @@ -554,13 +560,18 @@ inline quantity ratel( const fn_args& args ) { } if( !injection ) sum *= -1; - if (phase == rt::polymer || phase == rt::brine) return { sum, measure::mass_rate }; - return { sum, rate_unit< phase >() }; + return { sum, unit }; } template< rt phase, bool injection = true > inline quantity cratel( const fn_args& args ) { - const quantity zero = { 0, rate_unit< phase >() }; + const auto unit = ((phase == rt::polymer) || (phase == rt::brine)) + ? measure::mass_rate : rate_unit(); + + const quantity zero = { 0.0, unit }; + + if (args.schedule_wells.empty()) + return zero; const auto& well = args.schedule_wells.front(); const auto& name = well.name(); @@ -586,8 +597,7 @@ inline quantity cratel( const fn_args& args ) { } if( !injection ) sum *= -1; - if (phase == rt::polymer || phase == rt::brine) return { sum, measure::mass_rate }; - return { sum, rate_unit< phase >() }; + return { sum, unit }; }