From 06f32f3d37a8f6f9e1df1a21bc968b00bb1ead3c Mon Sep 17 00:00:00 2001 From: Williham Williham Totland Date: Fri, 24 Apr 2020 09:49:18 +0200 Subject: [PATCH 01/12] Projects unit type into columns. --- src/opm/output/eclipse/report/WELSPECS.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/opm/output/eclipse/report/WELSPECS.cpp b/src/opm/output/eclipse/report/WELSPECS.cpp index 58852c222..f86c6aedb 100644 --- a/src/opm/output/eclipse/report/WELSPECS.cpp +++ b/src/opm/output/eclipse/report/WELSPECS.cpp @@ -24,6 +24,7 @@ #include #include +#include namespace { @@ -80,7 +81,7 @@ namespace { return s; } - template + template struct column { using fetch_function = std::function; using format_function = std::function; @@ -109,9 +110,9 @@ namespace { } }; - template - struct table: std::vector> { - using std::vector>::vector; + template + struct table: std::vector> { + using std::vector>::vector; std::size_t total_width() const { std::size_t r { 1 + this->size() } ; @@ -158,15 +159,15 @@ namespace { }; - template + template struct report { std::string title; std::string decor; - table column_definition; + table column_definition; const context ctx; - report(const std::string& _title, const table& _coldef, const context& _ctx) + report(const std::string& _title, const table& _coldef, const context& _ctx) : title { _title } , decor { underline(title) } , column_definition { _coldef } From a62fdad1923187dbef0b67269205839c06b4cf2c Mon Sep 17 00:00:00 2001 From: Williham Williham Totland Date: Fri, 24 Apr 2020 10:26:21 +0200 Subject: [PATCH 02/12] Reworks projection of the unit system. --- src/opm/output/eclipse/report/WELSPECS.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/opm/output/eclipse/report/WELSPECS.cpp b/src/opm/output/eclipse/report/WELSPECS.cpp index f86c6aedb..91aa93e0c 100644 --- a/src/opm/output/eclipse/report/WELSPECS.cpp +++ b/src/opm/output/eclipse/report/WELSPECS.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -81,7 +82,7 @@ namespace { return s; } - template + template struct column { using fetch_function = std::function; using format_function = std::function; @@ -92,6 +93,8 @@ namespace { fetch_function fetch = unimplemented; format_function format = centre_align; + std::optional dimension = std::nullopt; + void print(std::ostream& os, const T& data, const context& ctx, std::size_t sub_report, std::size_t line_number) const { std::string string_data { fetch(data, ctx, sub_report, line_number) } ; format(string_data, internal_width, line_number); @@ -110,9 +113,9 @@ namespace { } }; - template - struct table: std::vector> { - using std::vector>::vector; + template + struct table: std::vector> { + using std::vector>::vector; std::size_t total_width() const { std::size_t r { 1 + this->size() } ; @@ -159,15 +162,15 @@ namespace { }; - template + template struct report { std::string title; std::string decor; - table column_definition; + table column_definition; const context ctx; - report(const std::string& _title, const table& _coldef, const context& _ctx) + report(const std::string& _title, const table& _coldef, const context& _ctx) : title { _title } , decor { underline(title) } , column_definition { _coldef } From e365ca3f7d02bd922061b21a184b8765ac715982 Mon Sep 17 00:00:00 2001 From: Williham Williham Totland Date: Fri, 24 Apr 2020 10:39:20 +0200 Subject: [PATCH 03/12] Projects the context into header printing. --- src/opm/output/eclipse/report/WELSPECS.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/opm/output/eclipse/report/WELSPECS.cpp b/src/opm/output/eclipse/report/WELSPECS.cpp index 91aa93e0c..4e707f5dd 100644 --- a/src/opm/output/eclipse/report/WELSPECS.cpp +++ b/src/opm/output/eclipse/report/WELSPECS.cpp @@ -102,10 +102,18 @@ namespace { os << string_data; } - void print_header(std::ostream& os, std::size_t row) const { - std::string header_line { header[row] } ; - centre_align(header_line, total_width()); - os << header_line; + std::string header_line(std::size_t row, context ctx) const { + if (row == header_height && dimension) { + return ""; + } else { + return header[row]; + } + } + + void print_header(std::ostream& os, std::size_t row, context ctx) const { + std::string line { header_line(row, ctx) } ; + centre_align(line, total_width()); + os << line; } constexpr std::size_t total_width() const { @@ -131,13 +139,13 @@ namespace { os << std::string(total_width(), padding) << record_separator; } - void print_header(std::ostream& os) const { + void print_header(std::ostream& os, context ctx) const { print_divider(os); for (size_t i { 0 }; i < header_height; ++i) { for (const auto& column : *this) { os << field_separator; - column.print_header(os, i); + column.print_header(os, i, ctx); } os << field_separator << record_separator; @@ -188,7 +196,7 @@ namespace { os << title << record_separator; os << decor << record_separator; os << section_separator; - column_definition.print_header(os); + column_definition.print_header(os, ctx); } void print_data(std::ostream& os, const std::vector& data, std::size_t sub_report, char bottom_border = '-') const { From 40a8651d684d2df230d5c3a12c318a1c03b1bdf3 Mon Sep 17 00:00:00 2001 From: Williham Williham Totland Date: Fri, 24 Apr 2020 11:02:11 +0200 Subject: [PATCH 04/12] Adds units to table definitions. --- src/opm/output/eclipse/report/WELSPECS.cpp | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/opm/output/eclipse/report/WELSPECS.cpp b/src/opm/output/eclipse/report/WELSPECS.cpp index 4e707f5dd..86bddf951 100644 --- a/src/opm/output/eclipse/report/WELSPECS.cpp +++ b/src/opm/output/eclipse/report/WELSPECS.cpp @@ -104,7 +104,7 @@ namespace { std::string header_line(std::size_t row, context ctx) const { if (row == header_height && dimension) { - return ""; + return ctx.unit_system.name(dimension.value()); } else { return header[row]; } @@ -351,9 +351,9 @@ namespace { { 8, { "WELL" , "NAME" , }, &WellWrapper::well_name , left_align }, { 8, { "GROUP" , "NAME" , }, &WellWrapper::group_name , left_align }, { 8, { "WELLHEAD" , "LOCATION" , "( I, J )" }, &WellWrapper::wellhead_location, left_align }, - { 8, { "B.H.REF" , "DEPTH" , "METRES" }, &WellWrapper::reference_depth , right_align }, + { 8, { "B.H.REF" , "DEPTH" , "METRES" }, &WellWrapper::reference_depth , right_align, Opm::UnitSystem::measure::length }, { 5, { "PREF-" , "ERRED" , "PHASE" }, &WellWrapper::preferred_phase , }, - { 8, { "DRAINAGE" , "RADIUS" , "METRES" }, &WellWrapper::drainage_radius , }, + { 8, { "DRAINAGE" , "RADIUS" , "METRES" }, &WellWrapper::drainage_radius , right_align, Opm::UnitSystem::measure::length }, { 4, { "GAS" , "INFL" , "EQUN" }, &WellWrapper::gas_inflow , }, { 7, { "SHUT-IN" , "INSTRCT" , }, &WellWrapper::shut_status , }, { 5, { "CROSS" , "FLOW" , "ABLTY" }, &WellWrapper::cross_flow , }, @@ -454,11 +454,11 @@ namespace { { 7, {"WELL" ,"NAME" , }, &WellConnection::well_name , left_align }, { 12, {"GRID" ,"BLOCK" , }, &WellConnection::grid_block , }, { 3, {"CMPL" ,"NO#" , }, &WellConnection::cmpl_no , right_align }, - { 7, {"CENTRE" ,"DEPTH" ,"METRES" }, &WellConnection::centre_depth , right_align }, + { 7, {"CENTRE" ,"DEPTH" ,"METRES" }, &WellConnection::centre_depth , right_align, Opm::UnitSystem::measure::length }, { 3, {"OPEN" ,"SHUT" , }, &WellConnection::open_shut , }, { 3, {"SAT" ,"TAB" , }, &WellConnection::sat_tab , }, { 8, {"CONNECTION" ,"FACTOR*" ,"CPM3/D/B" }, &WellConnection::conn_factor , right_align }, - { 6, {"INT" ,"DIAM" ,"METRES" }, &WellConnection::int_diam , right_align }, + { 6, {"INT" ,"DIAM" ,"METRES" }, &WellConnection::int_diam , right_align, Opm::UnitSystem::measure::length }, { 7, {"K H" ,"VALUE" ,"MD.METRE" }, &WellConnection::kh_value , right_align }, { 6, {"SKIN" ,"FACTOR" , }, &WellConnection::skin_factor , right_align }, { 10, {"CONNECTION" ,"D-FACTOR 1" ,"DAY/SM3" }, &WellConnection::dfactor , }, @@ -654,13 +654,13 @@ namespace { { 9, {"CONNECTION" , "" , }, &SegmentConnection::connection_grid , }, { 5, {"SEGMENT" , "NUMBER" , }, &SegmentConnection::segment_number , right_align }, { 8, {"BRANCH" , "ID" , }, &SegmentConnection::branch_id , }, - { 9, {"TUB LENGTH" , "START PERFS", "METRES" }, unimplemented , right_align }, - { 9, {"TUB LENGTH" , "END PERFS" , "METRES" }, unimplemented , right_align }, - { 9, {"TUB LENGTH" , "CENTR PERFS", "METRES" }, unimplemented , right_align }, - { 9, {"TUB LENGTH" , "END SEGMT" , "METRES" }, &SegmentConnection::length_end_segmt , right_align }, - { 8, {"CONNECTION" , "DEPTH" , "METRES" }, &SegmentConnection::connection_depth , right_align }, - { 8, {"SEGMENT" , "DEPTH" , "METRES" }, &SegmentConnection::segment_depth , right_align }, - { 9, {"GRID BLOCK" , "DEPTH" , "METRES" }, &SegmentConnection::grid_block_depth , right_align }, + { 9, {"TUB LENGTH" , "START PERFS", "METRES" }, unimplemented , right_align, Opm::UnitSystem::measure::length }, + { 9, {"TUB LENGTH" , "END PERFS" , "METRES" }, unimplemented , right_align, Opm::UnitSystem::measure::length }, + { 9, {"TUB LENGTH" , "CENTR PERFS", "METRES" }, unimplemented , right_align, Opm::UnitSystem::measure::length }, + { 9, {"TUB LENGTH" , "END SEGMT" , "METRES" }, &SegmentConnection::length_end_segmt , right_align, Opm::UnitSystem::measure::length }, + { 8, {"CONNECTION" , "DEPTH" , "METRES" }, &SegmentConnection::connection_depth , right_align, Opm::UnitSystem::measure::length }, + { 8, {"SEGMENT" , "DEPTH" , "METRES" }, &SegmentConnection::segment_depth , right_align, Opm::UnitSystem::measure::length }, + { 9, {"GRID BLOCK" , "DEPTH" , "METRES" }, &SegmentConnection::grid_block_depth , right_align, Opm::UnitSystem::measure::length }, }; const table msw_well_table = { @@ -669,14 +669,14 @@ namespace { { 3, { "BRN" , "NO" , "" }, &WellSegment::branch_number , right_align }, { 5, { "MAIN" , "INLET" , "SEGMENT" }, &WellSegment::main_inlet , right_align }, { 5, { "" , "OUTLET" , "SEGMENT" }, &WellSegment::outlet , right_align }, - { 7, { "SEGMENT" , "LENGTH" , "METRES" }, &WellSegment::length , right_align }, - { 8, { "TOT LENGTH", "TO END" , "METRES" }, &WellSegment::total_length , right_align }, - { 8, { "DEPTH" , "CHANGE" , "METRES" }, &WellSegment::depth_change , right_align }, - { 8, { "T.V. DEPTH", "AT END" , "METRES" }, &WellSegment::t_v_depth , right_align }, - { 6, { "DIA OR F" , "SCALING" , "METRES" }, &WellSegment::internal_diameter , right_align }, - { 8, { "VFP TAB OR", "ABS ROUGHN" , "METRES" }, &WellSegment::roughness , right_align }, - { 7, { "AREA" , "X-SECTN" , "M**2" }, &WellSegment::cross_section , right_align }, - { 7, { "VOLUME" , "" , "M3" }, &WellSegment::volume , right_align }, + { 7, { "SEGMENT" , "LENGTH" , "METRES" }, &WellSegment::length , right_align , Opm::UnitSystem::measure::length }, + { 8, { "TOT LENGTH", "TO END" , "METRES" }, &WellSegment::total_length , right_align , Opm::UnitSystem::measure::length }, + { 8, { "DEPTH" , "CHANGE" , "METRES" }, &WellSegment::depth_change , right_align , Opm::UnitSystem::measure::length }, + { 8, { "T.V. DEPTH", "AT END" , "METRES" }, &WellSegment::t_v_depth , right_align , Opm::UnitSystem::measure::length }, + { 6, { "DIA OR F" , "SCALING" , "METRES" }, &WellSegment::internal_diameter , right_align , Opm::UnitSystem::measure::length }, + { 8, { "VFP TAB OR", "ABS ROUGHN" , "METRES" }, &WellSegment::roughness , right_align , Opm::UnitSystem::measure::length }, + { 7, { "AREA" , "X-SECTN" , "M**2" }, &WellSegment::cross_section , right_align }, + { 7, { "VOLUME" , "" , "M3" }, &WellSegment::volume , right_align , Opm::UnitSystem::measure::volume }, { 8, { "P DROP" , "MULT" , "FACTOR 1" }, &WellSegment::pressure_drop_mult , right_align }, }; } From 84ff359b6467030ebc8d33ed104addc05b67b6bf Mon Sep 17 00:00:00 2001 From: Williham Williham Totland Date: Fri, 24 Apr 2020 11:16:45 +0200 Subject: [PATCH 05/12] Minor formatting tweaks. --- src/opm/output/eclipse/report/WELSPECS.cpp | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/opm/output/eclipse/report/WELSPECS.cpp b/src/opm/output/eclipse/report/WELSPECS.cpp index 86bddf951..7b06693d6 100644 --- a/src/opm/output/eclipse/report/WELSPECS.cpp +++ b/src/opm/output/eclipse/report/WELSPECS.cpp @@ -90,10 +90,10 @@ namespace { std::size_t internal_width; std::array header; - fetch_function fetch = unimplemented; - format_function format = centre_align; + fetch_function fetch { unimplemented } ; + format_function format { centre_align } ; - std::optional dimension = std::nullopt; + std::optional dimension { std::nullopt } ; void print(std::ostream& os, const T& data, const context& ctx, std::size_t sub_report, std::size_t line_number) const { std::string string_data { fetch(data, ctx, sub_report, line_number) } ; @@ -154,7 +154,7 @@ namespace { } void print_data(std::ostream& os, const std::vector& lines, const context& ctx, std::size_t sub_report) const { - std::size_t line_number = 0; + std::size_t line_number { 0 } ; for (const auto& line : lines) { for (const auto& column : *this) { @@ -581,8 +581,8 @@ namespace { if (segment.segmentNumber() == 1) return total_length(ctx, sub_report, line_number); - const auto& segments = well.getSegments(); - const auto& outlet_segment = segments.getFromSegmentNumber( segment.outletSegment() ); + const auto& segments { well.getSegments() } ; + const auto& outlet_segment { segments.getFromSegmentNumber( segment.outletSegment() ) } ; return std::to_string( segment.totalLength() - outlet_segment.totalLength() ).substr(0, 6); } @@ -594,8 +594,8 @@ namespace { if (segment.segmentNumber() == 1) return t_v_depth(ctx, sub_report, line_number); - const auto& segments = well.getSegments(); - const auto& outlet_segment = segments.getFromSegmentNumber( segment.outletSegment() ); + const auto& segments { well.getSegments() } ; + const auto& outlet_segment { segments.getFromSegmentNumber( segment.outletSegment() ) } ; return std::to_string( segment.depth() - outlet_segment.depth() ).substr(0, 6); } @@ -649,7 +649,7 @@ namespace { }; - const table msw_connection_table = { + const table msw_connection_table { { 8, {"WELL" , "NAME" , }, &SegmentConnection::well_name , left_header }, { 9, {"CONNECTION" , "" , }, &SegmentConnection::connection_grid , }, { 5, {"SEGMENT" , "NUMBER" , }, &SegmentConnection::segment_number , right_align }, @@ -663,7 +663,7 @@ namespace { { 9, {"GRID BLOCK" , "DEPTH" , "METRES" }, &SegmentConnection::grid_block_depth , right_align, Opm::UnitSystem::measure::length }, }; - const table msw_well_table = { + const table msw_well_table { { 6, { "WELLNAME" , "AND" , "SEG TYPE" }, &WellSegment::well_name_seg , &WellSegment::ws_format }, { 3, { "SEG" , "NO" , "" }, &WellSegment::segment_number , right_align }, { 3, { "BRN" , "NO" , "" }, &WellSegment::branch_number , right_align }, @@ -687,10 +687,10 @@ void report_well_connection_data(std::ostream& os, const std::vector& const report well_connection { "WELL CONNECTION DATA", connection_table, ctx}; well_connection.print_header(os); - std::size_t sub_report = 0; + std::size_t sub_report { 0 } ; for (const auto& well : data) { std::vector wrapper_data; - const auto& connections = well.getConnections(); + const auto& connections { well.getConnections() } ; std::transform(connections.begin(), connections.end(), std::back_inserter(wrapper_data), [&well]( const Opm::Connection& connection) { return WellConnection(well, connection); }); well_connection.print_data(os, wrapper_data, sub_report); @@ -703,11 +703,11 @@ void report_well_connection_data(std::ostream& os, const std::vector& } void Opm::RptIO::workers::write_WELSPECS(std::ostream& os, unsigned, const Opm::Schedule& schedule, const Opm::EclipseGrid& grid, std::size_t report_step) { - auto well_names = schedule.changed_wells(report_step); + auto well_names { schedule.changed_wells(report_step) } ; if (well_names.empty()) return; - context ctx{schedule, grid}; + context ctx { schedule, grid, unit_system } ; std::vector changed_wells; std::transform(well_names.begin(), well_names.end(), std::back_inserter(changed_wells), [&report_step, &schedule](const std::string& wname) { return schedule.getWell(wname, report_step); }); @@ -720,11 +720,11 @@ void Opm::RptIO::workers::write_WELSPECS(std::ostream& os, unsigned, const Opm:: { const report msw_data { "MULTI-SEGMENT WELL: SEGMENT STRUCTURE", msw_well_table, ctx}; msw_data.print_header(os); - std::size_t sub_report = 0; - const auto& segments = well.getSegments(); + std::size_t sub_report { 0 } ; + const auto& segments { well.getSegments() } ; for (const auto& branch : segments.branches()) { std::vector wrapper_data; - const auto& branch_segments = segments.branchSegments(branch); + const auto& branch_segments { segments.branchSegments(branch) } ; std::transform(branch_segments.begin(), branch_segments.end(), std::back_inserter(wrapper_data), [&well](const Opm::Segment& segment) { return WellSegment(well, segment); }); sub_report++; @@ -740,8 +740,8 @@ void Opm::RptIO::workers::write_WELSPECS(std::ostream& os, unsigned, const Opm:: msw_connection.print_header(os); { std::vector wrapper_data; - const auto& connections = well.getConnections(); - const auto& segments = well.getSegments(); + const auto& connections { well.getConnections() } ; + const auto& segments { well.getSegments() } ; std::transform(connections.begin(), connections.end(), std::back_inserter(wrapper_data), [&well, &segments] (const Opm::Connection& connection) { return SegmentConnection(well, connection, segments.getFromSegmentNumber(connection.segment())); }); msw_connection.print_data(os, wrapper_data, 0, '='); From 5e5aadb4eab1abd5576e40807877294b1a621e94 Mon Sep 17 00:00:00 2001 From: Williham Williham Totland Date: Fri, 24 Apr 2020 14:53:31 +0200 Subject: [PATCH 06/12] Adds unit conversions. --- src/opm/output/eclipse/report/WELSPECS.cpp | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/opm/output/eclipse/report/WELSPECS.cpp b/src/opm/output/eclipse/report/WELSPECS.cpp index 7b06693d6..d385d2d66 100644 --- a/src/opm/output/eclipse/report/WELSPECS.cpp +++ b/src/opm/output/eclipse/report/WELSPECS.cpp @@ -294,8 +294,8 @@ namespace { return i + ", " + j; } - std::string reference_depth(const context&, std::size_t, std::size_t) const { - return std::to_string(well.getRefDepth()).substr(0,6); + std::string reference_depth(const context& ctx, std::size_t, std::size_t) const { + return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, well.getRefDepth())).substr(0,6); } std::string preferred_phase(const context&, std::size_t, std::size_t) const { @@ -336,10 +336,10 @@ namespace { return well.getAllowCrossFlow() ? "YES" : "NO"; } - std::string drainage_radius(const context&, std::size_t, std::size_t) const { + std::string drainage_radius(const context& ctx, std::size_t, std::size_t) const { if (well.getDrainageRadius() == 0) return "P.EQUIV.R"; - return std::to_string(well.getDrainageRadius()).substr(0,6); + return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, well.getDrainageRadius())).substr(0,6); } std::string gas_inflow(const context&, std::size_t, std::size_t) const { @@ -412,8 +412,8 @@ namespace { return std::to_string(connection.complnum()); } - std::string centre_depth(const context&, std::size_t, std::size_t) const { - return std::to_string(connection.depth()).substr(0, 6); + std::string centre_depth(const context& ctx, std::size_t, std::size_t) const { + return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, connection.depth())).substr(0, 6); } std::string open_shut(const context&, std::size_t, std::size_t) const { @@ -428,8 +428,8 @@ namespace { return std::to_string(connection.CF()).substr(0, 10); } - std::string int_diam(const context&, std::size_t, std::size_t) const { - return std::to_string(connection.rw() * 2).substr(0, 8); + std::string int_diam(const context& ctx, std::size_t, std::size_t) const { + return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, connection.rw()) * 2).substr(0, 8); } std::string kh_value(const context&, std::size_t, std::size_t) const { @@ -498,20 +498,20 @@ namespace { return std::to_string(segment.branchNumber()); } - std::string length_end_segmt(const context&, std::size_t, std::size_t) const { - return std::to_string(segment.totalLength()).substr(0, 6); + std::string length_end_segmt(const context& ctx, std::size_t, std::size_t) const { + return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, segment.totalLength())).substr(0, 6); } - std::string connection_depth(const context&, std::size_t, std::size_t) const { - return std::to_string(connection.depth()).substr(0, 6); + std::string connection_depth(const context& ctx, std::size_t, std::size_t) const { + return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, connection.depth())).substr(0, 6); } - std::string segment_depth(const context&, std::size_t, std::size_t) const { - return std::to_string(segment.depth()).substr(0, 6); + std::string segment_depth(const context& ctx, std::size_t, std::size_t) const { + return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, segment.depth())).substr(0, 6); } std::string grid_block_depth(const context& ctx, std::size_t, std::size_t) const { - return std::to_string( ctx.grid.getCellDepth( connection.global_index() )).substr(0,6); + return std::to_string( ctx.unit_system.from_si(Opm::UnitSystem::measure::length, ctx.grid.getCellDepth( connection.global_index() ) )).substr(0,6); } @@ -573,8 +573,8 @@ namespace { return std::to_string(segment.outletSegment()); } - std::string total_length(const context&, std::size_t, std::size_t) const { - return std::to_string(segment.totalLength()).substr(0, 6); + std::string total_length(const context& ctx, std::size_t, std::size_t) const { + return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, segment.totalLength())).substr(0, 6); } std::string length(const context& ctx, std::size_t sub_report, std::size_t line_number) const { @@ -583,11 +583,11 @@ namespace { const auto& segments { well.getSegments() } ; const auto& outlet_segment { segments.getFromSegmentNumber( segment.outletSegment() ) } ; - return std::to_string( segment.totalLength() - outlet_segment.totalLength() ).substr(0, 6); + return std::to_string( ctx.unit_system.from_si(Opm::UnitSystem::measure::length, segment.totalLength() - outlet_segment.totalLength()) ).substr(0, 6); } - std::string t_v_depth(const context&, std::size_t, std::size_t) const { - return std::to_string(segment.depth()).substr(0, 6); + std::string t_v_depth(const context& ctx, std::size_t, std::size_t) const { + return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, segment.depth())).substr(0, 6); } std::string depth_change(const context& ctx, std::size_t sub_report, std::size_t line_number) const { @@ -596,24 +596,24 @@ namespace { const auto& segments { well.getSegments() } ; const auto& outlet_segment { segments.getFromSegmentNumber( segment.outletSegment() ) } ; - return std::to_string( segment.depth() - outlet_segment.depth() ).substr(0, 6); + return std::to_string( ctx.unit_system.from_si(Opm::UnitSystem::measure::length, segment.depth() - outlet_segment.depth()) ).substr(0, 6); } - std::string internal_diameter(const context&, std::size_t, std::size_t) const { + std::string internal_diameter(const context& ctx, std::size_t, std::size_t) const { const auto number { segment.internalDiameter() } ; if (number != Opm::Segment::invalidValue()) { - return std::to_string(number).substr(0, 6); + return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, number)).substr(0, 6); } else { return "0"; } } - std::string roughness(const context&, std::size_t, std::size_t) const { + std::string roughness(const context& ctx, std::size_t, std::size_t) const { const auto number { segment.roughness() } ; if (number != Opm::Segment::invalidValue()) { - return std::to_string(number).substr(0, 8); + return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, number)).substr(0, 8); } else { return "0"; } @@ -629,8 +629,8 @@ namespace { } } - std::string volume(const context&, std::size_t, std::size_t) const { - return std::to_string(segment.volume()).substr(0, 5); + std::string volume(const context& ctx, std::size_t, std::size_t) const { + return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::volume, segment.volume())).substr(0, 5); } std::string pressure_drop_mult(const context&, std::size_t, std::size_t) const { From 305b4b21a77b3c6807b05d53a1aaf20decb29096 Mon Sep 17 00:00:00 2001 From: Williham Williham Totland Date: Fri, 24 Apr 2020 15:35:39 +0200 Subject: [PATCH 07/12] Implements unit conversion for connection factor. --- src/opm/output/eclipse/report/WELSPECS.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/opm/output/eclipse/report/WELSPECS.cpp b/src/opm/output/eclipse/report/WELSPECS.cpp index d385d2d66..3af9f57d7 100644 --- a/src/opm/output/eclipse/report/WELSPECS.cpp +++ b/src/opm/output/eclipse/report/WELSPECS.cpp @@ -424,8 +424,8 @@ namespace { return std::to_string(connection.satTableId()); } - std::string conn_factor(const context&, std::size_t, std::size_t) const { - return std::to_string(connection.CF()).substr(0, 10); + std::string conn_factor(const context& ctx, std::size_t, std::size_t) const { + return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::transmissibility, connection.CF())).substr(0, 10); } std::string int_diam(const context& ctx, std::size_t, std::size_t) const { @@ -454,11 +454,11 @@ namespace { { 7, {"WELL" ,"NAME" , }, &WellConnection::well_name , left_align }, { 12, {"GRID" ,"BLOCK" , }, &WellConnection::grid_block , }, { 3, {"CMPL" ,"NO#" , }, &WellConnection::cmpl_no , right_align }, - { 7, {"CENTRE" ,"DEPTH" ,"METRES" }, &WellConnection::centre_depth , right_align, Opm::UnitSystem::measure::length }, + { 7, {"CENTRE" ,"DEPTH" ,"METRES" }, &WellConnection::centre_depth , right_align, Opm::UnitSystem::measure::length }, { 3, {"OPEN" ,"SHUT" , }, &WellConnection::open_shut , }, { 3, {"SAT" ,"TAB" , }, &WellConnection::sat_tab , }, - { 8, {"CONNECTION" ,"FACTOR*" ,"CPM3/D/B" }, &WellConnection::conn_factor , right_align }, - { 6, {"INT" ,"DIAM" ,"METRES" }, &WellConnection::int_diam , right_align, Opm::UnitSystem::measure::length }, + { 11, {"CONNECTION" ,"FACTOR*" ,"CPM3/D/B" }, &WellConnection::conn_factor , right_align, Opm::UnitSystem::measure::transmissibility }, + { 6, {"INT" ,"DIAM" ,"METRES" }, &WellConnection::int_diam , right_align, Opm::UnitSystem::measure::length }, { 7, {"K H" ,"VALUE" ,"MD.METRE" }, &WellConnection::kh_value , right_align }, { 6, {"SKIN" ,"FACTOR" , }, &WellConnection::skin_factor , right_align }, { 10, {"CONNECTION" ,"D-FACTOR 1" ,"DAY/SM3" }, &WellConnection::dfactor , }, From fbe9d0dec2d4c56a1433c250dc4afa05cdb8c25f Mon Sep 17 00:00:00 2001 From: Williham Williham Totland Date: Fri, 24 Apr 2020 16:17:28 +0200 Subject: [PATCH 08/12] Refactors number formatting. --- src/opm/output/eclipse/report/WELSPECS.cpp | 36 ++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/opm/output/eclipse/report/WELSPECS.cpp b/src/opm/output/eclipse/report/WELSPECS.cpp index 3af9f57d7..254f2253c 100644 --- a/src/opm/output/eclipse/report/WELSPECS.cpp +++ b/src/opm/output/eclipse/report/WELSPECS.cpp @@ -75,6 +75,10 @@ namespace { const Opm::EclipseGrid& grid; }; + std::string format_number(const Opm::UnitSystem& unit_system, Opm::UnitSystem::measure measure, double number, std::size_t width) { + return std::to_string(unit_system.from_si(measure, number)).substr(0, width); + } + template const std::string& unimplemented(const T&, const context&, std::size_t, std::size_t) { static const std::string s { } ; @@ -295,7 +299,7 @@ namespace { } std::string reference_depth(const context& ctx, std::size_t, std::size_t) const { - return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, well.getRefDepth())).substr(0,6); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, well.getRefDepth(), 6); } std::string preferred_phase(const context&, std::size_t, std::size_t) const { @@ -339,7 +343,7 @@ namespace { std::string drainage_radius(const context& ctx, std::size_t, std::size_t) const { if (well.getDrainageRadius() == 0) return "P.EQUIV.R"; - return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, well.getDrainageRadius())).substr(0,6); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, well.getDrainageRadius(), 6); } std::string gas_inflow(const context&, std::size_t, std::size_t) const { @@ -413,7 +417,7 @@ namespace { } std::string centre_depth(const context& ctx, std::size_t, std::size_t) const { - return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, connection.depth())).substr(0, 6); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, connection.depth(), 6); } std::string open_shut(const context&, std::size_t, std::size_t) const { @@ -425,11 +429,11 @@ namespace { } std::string conn_factor(const context& ctx, std::size_t, std::size_t) const { - return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::transmissibility, connection.CF())).substr(0, 10); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::transmissibility, connection.CF(), 10); } std::string int_diam(const context& ctx, std::size_t, std::size_t) const { - return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, connection.rw()) * 2).substr(0, 8); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, connection.rw() * 2, 8); } std::string kh_value(const context&, std::size_t, std::size_t) const { @@ -499,19 +503,19 @@ namespace { } std::string length_end_segmt(const context& ctx, std::size_t, std::size_t) const { - return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, segment.totalLength())).substr(0, 6); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, segment.totalLength(), 6); } std::string connection_depth(const context& ctx, std::size_t, std::size_t) const { - return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, connection.depth())).substr(0, 6); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, connection.depth(), 6); } std::string segment_depth(const context& ctx, std::size_t, std::size_t) const { - return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, segment.depth())).substr(0, 6); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, segment.depth(), 6); } std::string grid_block_depth(const context& ctx, std::size_t, std::size_t) const { - return std::to_string( ctx.unit_system.from_si(Opm::UnitSystem::measure::length, ctx.grid.getCellDepth( connection.global_index() ) )).substr(0,6); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, ctx.grid.getCellDepth( connection.global_index() ), 6); } @@ -574,7 +578,7 @@ namespace { } std::string total_length(const context& ctx, std::size_t, std::size_t) const { - return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, segment.totalLength())).substr(0, 6); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, segment.totalLength(), 6); } std::string length(const context& ctx, std::size_t sub_report, std::size_t line_number) const { @@ -583,11 +587,11 @@ namespace { const auto& segments { well.getSegments() } ; const auto& outlet_segment { segments.getFromSegmentNumber( segment.outletSegment() ) } ; - return std::to_string( ctx.unit_system.from_si(Opm::UnitSystem::measure::length, segment.totalLength() - outlet_segment.totalLength()) ).substr(0, 6); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, segment.totalLength() - outlet_segment.totalLength(), 6); } std::string t_v_depth(const context& ctx, std::size_t, std::size_t) const { - return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, segment.depth())).substr(0, 6); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, segment.depth(), 6); } std::string depth_change(const context& ctx, std::size_t sub_report, std::size_t line_number) const { @@ -596,14 +600,14 @@ namespace { const auto& segments { well.getSegments() } ; const auto& outlet_segment { segments.getFromSegmentNumber( segment.outletSegment() ) } ; - return std::to_string( ctx.unit_system.from_si(Opm::UnitSystem::measure::length, segment.depth() - outlet_segment.depth()) ).substr(0, 6); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, segment.depth() - outlet_segment.depth(), 6); } std::string internal_diameter(const context& ctx, std::size_t, std::size_t) const { const auto number { segment.internalDiameter() } ; if (number != Opm::Segment::invalidValue()) { - return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, number)).substr(0, 6); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, number, 6); } else { return "0"; } @@ -613,7 +617,7 @@ namespace { const auto number { segment.roughness() } ; if (number != Opm::Segment::invalidValue()) { - return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::length, number)).substr(0, 8); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, number, 8); } else { return "0"; } @@ -630,7 +634,7 @@ namespace { } std::string volume(const context& ctx, std::size_t, std::size_t) const { - return std::to_string(ctx.unit_system.from_si(Opm::UnitSystem::measure::volume, segment.volume())).substr(0, 5); + return format_number(ctx.unit_system, Opm::UnitSystem::measure::volume, segment.volume(), 5); } std::string pressure_drop_mult(const context&, std::size_t, std::size_t) const { From 78c19a3aba15bee63f55f9c9a39083d07c40965f Mon Sep 17 00:00:00 2001 From: Williham Williham Totland Date: Fri, 24 Apr 2020 16:38:09 +0200 Subject: [PATCH 09/12] Minor style tweaks. --- src/opm/output/eclipse/report/WELSPECS.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/opm/output/eclipse/report/WELSPECS.cpp b/src/opm/output/eclipse/report/WELSPECS.cpp index 254f2253c..8a5358f4d 100644 --- a/src/opm/output/eclipse/report/WELSPECS.cpp +++ b/src/opm/output/eclipse/report/WELSPECS.cpp @@ -209,9 +209,11 @@ namespace { } void print_footer(std::ostream& os, const std::vector>& footnotes) const { - for (const auto& fnote: footnotes) - os << fnote.first << ": " << fnote.second << std::endl; - os << std::endl << std::endl; + for (const auto& fnote: footnotes) { + os << fnote.first << ": " << fnote.second << record_separator; + } + + os << section_separator; } }; } @@ -323,9 +325,7 @@ namespace { } std::string dens_calc(const context&, std::size_t, std::size_t) const { - if (well.segmented_density_calculation()) - return "SEG"; - return "AVG"; + return well.segmented_density_calculation() ? "SEG" : "AVG"; } /* From a4111fa6726882c5c6fce6abf7a22a02836899b5 Mon Sep 17 00:00:00 2001 From: Williham Williham Totland Date: Wed, 29 Apr 2020 08:32:07 +0200 Subject: [PATCH 10/12] Projects the unit system from the callsite. --- opm/output/eclipse/WriteRPT.hpp | 4 +++- src/opm/output/eclipse/EclipseIO.cpp | 5 ++++- src/opm/output/eclipse/WriteRPT.cpp | 5 +++-- src/opm/output/eclipse/report/WELSPECS.cpp | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/opm/output/eclipse/WriteRPT.hpp b/opm/output/eclipse/WriteRPT.hpp index 3dc9cc054..d98913342 100644 --- a/opm/output/eclipse/WriteRPT.hpp +++ b/opm/output/eclipse/WriteRPT.hpp @@ -26,6 +26,7 @@ namespace Opm { class Schedule; class EclipseGrid; + class UnitSystem; namespace RptIO { @@ -35,12 +36,13 @@ namespace Opm { unsigned value, const Schedule& schedule, const EclipseGrid& grid, + const UnitSystem& unit_system, std::size_t time_step ); namespace workers { - void write_WELSPECS(std::ostream&, unsigned, const Schedule&, const EclipseGrid& grid, std::size_t); + void write_WELSPECS(std::ostream&, unsigned, const Schedule&, const EclipseGrid& grid, const UnitSystem&, std::size_t); } } } #endif // OPM_WRITE_RPT_HPP diff --git a/src/opm/output/eclipse/EclipseIO.cpp b/src/opm/output/eclipse/EclipseIO.cpp index 85f979cbb..50280094e 100644 --- a/src/opm/output/eclipse/EclipseIO.cpp +++ b/src/opm/output/eclipse/EclipseIO.cpp @@ -263,7 +263,10 @@ void EclipseIO::writeTimeStep(const SummaryState& st, if (!isSubstep) { for (const auto& report : schedule.report_config(report_step)) { std::stringstream ss; - RptIO::write_report(ss, report.first, report.second, schedule, grid, report_step); + const auto& unit_system = this->impl->es.getUnits(); + + RptIO::write_report(ss, report.first, report.second, schedule, grid, unit_system, report_step); + auto log_string = ss.str(); if (!log_string.empty()) OpmLog::note(log_string); diff --git a/src/opm/output/eclipse/WriteRPT.cpp b/src/opm/output/eclipse/WriteRPT.cpp index 2474bc773..d568d7407 100644 --- a/src/opm/output/eclipse/WriteRPT.cpp +++ b/src/opm/output/eclipse/WriteRPT.cpp @@ -24,7 +24,7 @@ namespace Opm::RptIO { - using report_function = std::function; + using report_function = std::function; static const std::unordered_map report_functions { { "WELSPECS", workers::write_WELSPECS }, @@ -36,11 +36,12 @@ namespace Opm::RptIO { unsigned value, const Opm::Schedule& schedule, const Opm::EclipseGrid& grid, + const Opm::UnitSystem& unit_system, std::size_t report_step ) { const auto function { report_functions.find(report) } ; if (function != report_functions.end()) { - function->second(os, value, schedule, grid, report_step); + function->second(os, value, schedule, grid, unit_system, report_step); } } } diff --git a/src/opm/output/eclipse/report/WELSPECS.cpp b/src/opm/output/eclipse/report/WELSPECS.cpp index 8a5358f4d..591828b08 100644 --- a/src/opm/output/eclipse/report/WELSPECS.cpp +++ b/src/opm/output/eclipse/report/WELSPECS.cpp @@ -73,6 +73,7 @@ namespace { struct context { const Opm::Schedule& sched; const Opm::EclipseGrid& grid; + const Opm::UnitSystem& unit_system; }; std::string format_number(const Opm::UnitSystem& unit_system, Opm::UnitSystem::measure measure, double number, std::size_t width) { @@ -706,7 +707,7 @@ void report_well_connection_data(std::ostream& os, const std::vector& } -void Opm::RptIO::workers::write_WELSPECS(std::ostream& os, unsigned, const Opm::Schedule& schedule, const Opm::EclipseGrid& grid, std::size_t report_step) { +void Opm::RptIO::workers::write_WELSPECS(std::ostream& os, unsigned, const Opm::Schedule& schedule, const Opm::EclipseGrid& grid, const Opm::UnitSystem& unit_system, std::size_t report_step) { auto well_names { schedule.changed_wells(report_step) } ; if (well_names.empty()) return; From 77a0ee13aca3dc295e9dcf6c8fcb5a573478a7de Mon Sep 17 00:00:00 2001 From: Williham Williham Totland Date: Wed, 29 Apr 2020 10:14:28 +0200 Subject: [PATCH 11/12] Implements perf range. --- src/opm/output/eclipse/report/WELSPECS.cpp | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/opm/output/eclipse/report/WELSPECS.cpp b/src/opm/output/eclipse/report/WELSPECS.cpp index 591828b08..9f9fc1309 100644 --- a/src/opm/output/eclipse/report/WELSPECS.cpp +++ b/src/opm/output/eclipse/report/WELSPECS.cpp @@ -478,11 +478,13 @@ namespace { const Opm::Connection& connection; const Opm::Segment& segment; + const std::pair& perf_range; - SegmentConnection(const Opm::Well& well_arg, const Opm::Connection& conn_arg, const Opm::Segment& segment_arg) : + SegmentConnection(const Opm::Well& well_arg, const Opm::Connection& conn_arg, const Opm::Segment& segment_arg, const std::pair& perf_range_arg) : well(well_arg), connection(conn_arg), - segment(segment_arg) + segment(segment_arg), + perf_range(perf_range_arg) {} const std::string& well_name(const context&, std::size_t, std::size_t) const { @@ -503,6 +505,18 @@ namespace { return std::to_string(segment.branchNumber()); } + std::string perf_start_length(const context& ctx, std::size_t, std::size_t) const { + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, perf_range.first, 6); + } + + std::string perf_mid_length(const context& ctx, std::size_t, std::size_t) const { + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, (perf_range.first + perf_range.second) / 2.0, 6); + } + + std::string perf_end_length(const context& ctx, std::size_t, std::size_t) const { + return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, perf_range.second, 6); + } + std::string length_end_segmt(const context& ctx, std::size_t, std::size_t) const { return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, segment.totalLength(), 6); } @@ -659,9 +673,9 @@ namespace { { 9, {"CONNECTION" , "" , }, &SegmentConnection::connection_grid , }, { 5, {"SEGMENT" , "NUMBER" , }, &SegmentConnection::segment_number , right_align }, { 8, {"BRANCH" , "ID" , }, &SegmentConnection::branch_id , }, - { 9, {"TUB LENGTH" , "START PERFS", "METRES" }, unimplemented , right_align, Opm::UnitSystem::measure::length }, - { 9, {"TUB LENGTH" , "END PERFS" , "METRES" }, unimplemented , right_align, Opm::UnitSystem::measure::length }, - { 9, {"TUB LENGTH" , "CENTR PERFS", "METRES" }, unimplemented , right_align, Opm::UnitSystem::measure::length }, + { 9, {"TUB LENGTH" , "START PERFS", "METRES" }, &SegmentConnection::perf_start_length, right_align, Opm::UnitSystem::measure::length }, + { 9, {"TUB LENGTH" , "END PERFS" , "METRES" }, &SegmentConnection::perf_end_length , right_align, Opm::UnitSystem::measure::length }, + { 9, {"TUB LENGTH" , "CENTR PERFS", "METRES" }, &SegmentConnection::perf_mid_length , right_align, Opm::UnitSystem::measure::length }, { 9, {"TUB LENGTH" , "END SEGMT" , "METRES" }, &SegmentConnection::length_end_segmt , right_align, Opm::UnitSystem::measure::length }, { 8, {"CONNECTION" , "DEPTH" , "METRES" }, &SegmentConnection::connection_depth , right_align, Opm::UnitSystem::measure::length }, { 8, {"SEGMENT" , "DEPTH" , "METRES" }, &SegmentConnection::segment_depth , right_align, Opm::UnitSystem::measure::length }, @@ -747,8 +761,9 @@ void Opm::RptIO::workers::write_WELSPECS(std::ostream& os, unsigned, const Opm:: std::vector wrapper_data; const auto& connections { well.getConnections() } ; const auto& segments { well.getSegments() } ; + const std::pair perf_range { } ; // TODO: connect with #1759 std::transform(connections.begin(), connections.end(), std::back_inserter(wrapper_data), - [&well, &segments] (const Opm::Connection& connection) { return SegmentConnection(well, connection, segments.getFromSegmentNumber(connection.segment())); }); + [&well, &segments, &perf_range] (const Opm::Connection& connection) { return SegmentConnection(well, connection, segments.getFromSegmentNumber(connection.segment()), perf_range); }); msw_connection.print_data(os, wrapper_data, 0, '='); } msw_connection.print_footer(os, {}); From cb8ddfd8aa076ee6d4ed05dd5ce3c962f68fa2b7 Mon Sep 17 00:00:00 2001 From: Williham Williham Totland Date: Wed, 29 Apr 2020 11:30:30 +0200 Subject: [PATCH 12/12] Minor style consistency tweaks. --- src/opm/output/eclipse/report/WELSPECS.cpp | 34 ++++------------------ 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/src/opm/output/eclipse/report/WELSPECS.cpp b/src/opm/output/eclipse/report/WELSPECS.cpp index 9f9fc1309..4a9e92a3e 100644 --- a/src/opm/output/eclipse/report/WELSPECS.cpp +++ b/src/opm/output/eclipse/report/WELSPECS.cpp @@ -280,10 +280,6 @@ namespace { struct WellWrapper { const Opm::Well& well; - WellWrapper(const Opm::Well& well_arg) : - well(well_arg) - { } - std::string well_name(const context&, std::size_t, std::size_t) const { return well.name(); } @@ -372,7 +368,7 @@ namespace { void report_well_specification_data(std::ostream& os, const std::vector& data, const context& ctx) { report well_specification { "WELL SPECIFICATION DATA", well_specification_table, ctx}; std::vector wrapper_data; - std::transform(data.begin(), data.end(), std::back_inserter(wrapper_data), [](const Opm::Well& well) { return WellWrapper(well); }); + std::transform(data.begin(), data.end(), std::back_inserter(wrapper_data), [](const Opm::Well& well) { return WellWrapper { well } ; }); well_specification.print_header(os); well_specification.print_data(os, wrapper_data, 0); @@ -387,12 +383,6 @@ namespace { const Opm::Well& well; const Opm::Connection& connection; - WellConnection(const Opm::Well& well_arg, const Opm::Connection& connection_arg) : - well(well_arg), - connection(connection_arg) - {} - - const std::string& well_name(const context&, std::size_t, std::size_t) const { return well.name(); } @@ -400,7 +390,7 @@ namespace { std::string grid_block(const context&, std::size_t, std::size_t) const { const std::array ijk { connection.getI() + 1, connection.getJ() + 1, connection.getK() + 1 } ; - auto compose_coordinates = [](std::string& out, int in) -> std::string { + auto compose_coordinates { [](std::string& out, int in) -> std::string { constexpr auto delimiter { ',' } ; std::string coordinate_part { std::to_string(in) } ; right_align(coordinate_part, 3); @@ -408,7 +398,7 @@ namespace { return out.empty() ? coordinate_part : out + delimiter + coordinate_part; - }; + } }; return std::accumulate(std::begin(ijk), std::end(ijk), std::string {}, compose_coordinates); } @@ -480,13 +470,6 @@ namespace { const std::pair& perf_range; - SegmentConnection(const Opm::Well& well_arg, const Opm::Connection& conn_arg, const Opm::Segment& segment_arg, const std::pair& perf_range_arg) : - well(well_arg), - connection(conn_arg), - segment(segment_arg), - perf_range(perf_range_arg) - {} - const std::string& well_name(const context&, std::size_t, std::size_t) const { return well.name(); } @@ -550,11 +533,6 @@ namespace { const Opm::Well& well; const Opm::Segment& segment; - WellSegment(const Opm::Well& well_arg, const Opm::Segment& segment_arg) : - well(well_arg), - segment(segment_arg) - {} - std::string well_name_seg(const context&, std::size_t sub_report, std::size_t n) const { if (sub_report > 0) return ""; @@ -710,7 +688,7 @@ void report_well_connection_data(std::ostream& os, const std::vector& for (const auto& well : data) { std::vector wrapper_data; const auto& connections { well.getConnections() } ; - std::transform(connections.begin(), connections.end(), std::back_inserter(wrapper_data), [&well]( const Opm::Connection& connection) { return WellConnection(well, connection); }); + std::transform(connections.begin(), connections.end(), std::back_inserter(wrapper_data), [&well](const Opm::Connection& connection) { return WellConnection { well, connection } ; }); well_connection.print_data(os, wrapper_data, sub_report); sub_report++; @@ -744,7 +722,7 @@ void Opm::RptIO::workers::write_WELSPECS(std::ostream& os, unsigned, const Opm:: for (const auto& branch : segments.branches()) { std::vector wrapper_data; const auto& branch_segments { segments.branchSegments(branch) } ; - std::transform(branch_segments.begin(), branch_segments.end(), std::back_inserter(wrapper_data), [&well](const Opm::Segment& segment) { return WellSegment(well, segment); }); + std::transform(branch_segments.begin(), branch_segments.end(), std::back_inserter(wrapper_data), [&well](const Opm::Segment& segment) { return WellSegment { well, segment } ; }); sub_report++; if (sub_report == (segments.branches().size())) @@ -763,7 +741,7 @@ void Opm::RptIO::workers::write_WELSPECS(std::ostream& os, unsigned, const Opm:: const auto& segments { well.getSegments() } ; const std::pair perf_range { } ; // TODO: connect with #1759 std::transform(connections.begin(), connections.end(), std::back_inserter(wrapper_data), - [&well, &segments, &perf_range] (const Opm::Connection& connection) { return SegmentConnection(well, connection, segments.getFromSegmentNumber(connection.segment()), perf_range); }); + [&well, &segments, &perf_range] (const Opm::Connection& connection) { return SegmentConnection { well, connection, segments.getFromSegmentNumber(connection.segment()), perf_range } ; }); msw_connection.print_data(os, wrapper_data, 0, '='); } msw_connection.print_footer(os, {});