From 746c39d0b86f6b0bb52a863ba364bd579f5abc4a Mon Sep 17 00:00:00 2001 From: Eivind Jahren Date: Fri, 23 Aug 2024 13:38:52 +0200 Subject: [PATCH 1/5] Remove unused c code in rd_coarse_cell --- lib/include/resdata/rd_coarse_cell.hpp | 11 ---- lib/resdata/rd_coarse_cell.cpp | 75 ++++++-------------------- 2 files changed, 17 insertions(+), 69 deletions(-) diff --git a/lib/include/resdata/rd_coarse_cell.hpp b/lib/include/resdata/rd_coarse_cell.hpp index 131ca3a87..5bfa95bed 100644 --- a/lib/include/resdata/rd_coarse_cell.hpp +++ b/lib/include/resdata/rd_coarse_cell.hpp @@ -15,17 +15,9 @@ void rd_coarse_cell_update(rd_coarse_cell_type *coarse_cell, int i, int j, void rd_coarse_cell_free(rd_coarse_cell_type *coarse_cell); void rd_coarse_cell_free__(void *arg); -int rd_coarse_cell_get_i1(const rd_coarse_cell_type *coarse_cell); -int rd_coarse_cell_get_j1(const rd_coarse_cell_type *coarse_cell); -int rd_coarse_cell_get_k1(const rd_coarse_cell_type *coarse_cell); -int rd_coarse_cell_get_i2(const rd_coarse_cell_type *coarse_cell); -int rd_coarse_cell_get_j2(const rd_coarse_cell_type *coarse_cell); -int rd_coarse_cell_get_k2(const rd_coarse_cell_type *coarse_cell); const int *rd_coarse_cell_get_box_ptr(const rd_coarse_cell_type *coarse_cell); int rd_coarse_cell_get_size(const rd_coarse_cell_type *coarse_cell); -int rd_coarse_cell_iget_cell_index(rd_coarse_cell_type *coarse_cell, - int group_index); const int *rd_coarse_cell_get_index_ptr(rd_coarse_cell_type *coarse_cell); const int_vector_type * rd_coarse_cell_get_index_vector(rd_coarse_cell_type *coarse_cell); @@ -42,9 +34,6 @@ int rd_coarse_cell_iget_active_cell_index( int rd_coarse_cell_iget_active_value(const rd_coarse_cell_type *coarse_cell, int index); int rd_coarse_cell_get_num_active(const rd_coarse_cell_type *coarse_cell); -void rd_coarse_cell_fprintf(const rd_coarse_cell_type *coarse_cell, - FILE *stream); - #ifdef __cplusplus } #endif diff --git a/lib/resdata/rd_coarse_cell.cpp b/lib/resdata/rd_coarse_cell.cpp index 1a6abd1e6..9db5d92ed 100644 --- a/lib/resdata/rd_coarse_cell.cpp +++ b/lib/resdata/rd_coarse_cell.cpp @@ -98,18 +98,7 @@ struct rd_coarse_cell_struct { int_vector_type *active_values; }; -static UTIL_SAFE_CAST_FUNCTION(rd_coarse_cell, RD_COARSE_CELL_TYPE_ID) - - void rd_coarse_cell_assert(rd_coarse_cell_type *coarse_cell) { - int box_size = (1 + coarse_cell->ijk[1] - coarse_cell->ijk[0]) * - (1 + coarse_cell->ijk[2] - coarse_cell->ijk[3]) * - (1 + coarse_cell->ijk[4] - coarse_cell->ijk[5]); - - if (box_size != int_vector_size(coarse_cell->cell_list)) - util_abort("%s: using invalid coarse cell. Box size:%d cells. " - "cell_list:%d cells \n", - __func__, box_size, int_vector_size(coarse_cell->cell_list)); -} +static UTIL_SAFE_CAST_FUNCTION(rd_coarse_cell, RD_COARSE_CELL_TYPE_ID); rd_coarse_cell_type *rd_coarse_cell_alloc() { const int LARGE = 1 << 30; @@ -134,6 +123,22 @@ rd_coarse_cell_type *rd_coarse_cell_alloc() { return coarse_cell; } +static void rd_coarse_cell_fprintf(const rd_coarse_cell_type *coarse_cell, + FILE *stream) { + fprintf(stream, "Coarse box: \n"); + fprintf(stream, " i : %3d - %3d\n", coarse_cell->ijk[0], + coarse_cell->ijk[1]); + fprintf(stream, " j : %3d - %3d\n", coarse_cell->ijk[2], + coarse_cell->ijk[3]); + fprintf(stream, " k : %3d - %3d\n", coarse_cell->ijk[4], + coarse_cell->ijk[5]); + fprintf(stream, " active_cells : "); + int_vector_fprintf(coarse_cell->active_cells, stream, "", "%5d "); + fprintf(stream, " active_values : "); + int_vector_fprintf(coarse_cell->active_values, stream, "", "%5d "); + //fprintf(stream," Cells : " ); int_vector_fprintf( coarse_cell->cell_list , stream , "" , "%5d "); +} + bool rd_coarse_cell_equal(const rd_coarse_cell_type *coarse_cell1, const rd_coarse_cell_type *coarse_cell2) { bool equal = true; @@ -211,12 +216,6 @@ int rd_coarse_cell_get_size(const rd_coarse_cell_type *coarse_cell) { return int_vector_size(coarse_cell->cell_list); } -int rd_coarse_cell_iget_cell_index(rd_coarse_cell_type *coarse_cell, - int group_index) { - rd_coarse_cell_sort(coarse_cell); - return int_vector_iget(coarse_cell->cell_list, group_index); -} - const int *rd_coarse_cell_get_index_ptr(rd_coarse_cell_type *coarse_cell) { rd_coarse_cell_sort(coarse_cell); return int_vector_get_const_ptr(coarse_cell->cell_list); @@ -228,30 +227,6 @@ rd_coarse_cell_get_index_vector(rd_coarse_cell_type *coarse_cell) { return coarse_cell->cell_list; } -int rd_coarse_cell_get_i1(const rd_coarse_cell_type *coarse_cell) { - return coarse_cell->ijk[0]; -} - -int rd_coarse_cell_get_i2(const rd_coarse_cell_type *coarse_cell) { - return coarse_cell->ijk[1]; -} - -int rd_coarse_cell_get_j1(const rd_coarse_cell_type *coarse_cell) { - return coarse_cell->ijk[2]; -} - -int rd_coarse_cell_get_j2(const rd_coarse_cell_type *coarse_cell) { - return coarse_cell->ijk[3]; -} - -int rd_coarse_cell_get_k1(const rd_coarse_cell_type *coarse_cell) { - return coarse_cell->ijk[4]; -} - -int rd_coarse_cell_get_k2(const rd_coarse_cell_type *coarse_cell) { - return coarse_cell->ijk[5]; -} - const int *rd_coarse_cell_get_box_ptr(const rd_coarse_cell_type *coarse_cell) { return coarse_cell->ijk; } @@ -317,19 +292,3 @@ int rd_coarse_cell_iget_active_value(const rd_coarse_cell_type *coarse_cell, int rd_coarse_cell_get_num_active(const rd_coarse_cell_type *coarse_cell) { return int_vector_size(coarse_cell->active_cells); } - -void rd_coarse_cell_fprintf(const rd_coarse_cell_type *coarse_cell, - FILE *stream) { - fprintf(stream, "Coarse box: \n"); - fprintf(stream, " i : %3d - %3d\n", coarse_cell->ijk[0], - coarse_cell->ijk[1]); - fprintf(stream, " j : %3d - %3d\n", coarse_cell->ijk[2], - coarse_cell->ijk[3]); - fprintf(stream, " k : %3d - %3d\n", coarse_cell->ijk[4], - coarse_cell->ijk[5]); - fprintf(stream, " active_cells : "); - int_vector_fprintf(coarse_cell->active_cells, stream, "", "%5d "); - fprintf(stream, " active_values : "); - int_vector_fprintf(coarse_cell->active_values, stream, "", "%5d "); - //fprintf(stream," Cells : " ); int_vector_fprintf( coarse_cell->cell_list , stream , "" , "%5d "); -} From 34ec57ace7085f72cf8d640cdc2fbf98461ee807 Mon Sep 17 00:00:00 2001 From: Eivind Jahren Date: Fri, 23 Aug 2024 13:43:25 +0200 Subject: [PATCH 2/5] Remove unused well_segment_free__ --- lib/include/resdata/well/well_segment.hpp | 1 - lib/resdata/well_segment.cpp | 19 ------------------- 2 files changed, 20 deletions(-) diff --git a/lib/include/resdata/well/well_segment.hpp b/lib/include/resdata/well/well_segment.hpp index c6ae44cce..b4973f01a 100644 --- a/lib/include/resdata/well/well_segment.hpp +++ b/lib/include/resdata/well/well_segment.hpp @@ -24,7 +24,6 @@ well_segment_alloc_from_kw(const rd_kw_type *iseg_kw, well_segment_type *well_segment_alloc(int segment_id, int outlet_segment_id, int branch_id, const double *rseg_data); void well_segment_free(well_segment_type *segment); -void well_segment_free__(void *arg); bool well_segment_active(const well_segment_type *segment); bool well_segment_main_stem(const well_segment_type *segment); diff --git a/lib/resdata/well_segment.cpp b/lib/resdata/well_segment.cpp index 237e84b8a..99099d565 100644 --- a/lib/resdata/well_segment.cpp +++ b/lib/resdata/well_segment.cpp @@ -98,20 +98,6 @@ well_segment_alloc_from_kw(const rd_kw_type *iseg_kw, } } -/* - if (iseg_kw != NULL) { - if (conn->segment != WELL_CONN_NORMAL_WELL_SEGMENT_ID) { - - } else { - conn->branch = 0; - conn->outlet_segment = 0; - } - } else { - conn->branch = 0; - conn->outlet_segment = 0; - } - */ - void well_segment_free(well_segment_type *segment) { for (auto &pair : segment->connections) well_conn_collection_free(pair.second); @@ -119,11 +105,6 @@ void well_segment_free(well_segment_type *segment) { delete segment; } -void well_segment_free__(void *arg) { - well_segment_type *segment = well_segment_safe_cast(arg); - well_segment_free(segment); -} - bool well_segment_active(const well_segment_type *segment) { if (segment->branch_id == WELL_SEGMENT_BRANCH_INACTIVE_VALUE) return false; From e8a18735b48c9f032c99a20ce46bb16b23cae5c1 Mon Sep 17 00:00:00 2001 From: Eivind Jahren Date: Fri, 23 Aug 2024 13:44:36 +0200 Subject: [PATCH 3/5] Remove unused rd_sum_index --- lib/include/resdata/rd_sum_index.hpp | 13 ------------- lib/resdata/rd_sum_index.cpp | 23 ----------------------- 2 files changed, 36 deletions(-) delete mode 100644 lib/include/resdata/rd_sum_index.hpp delete mode 100644 lib/resdata/rd_sum_index.cpp diff --git a/lib/include/resdata/rd_sum_index.hpp b/lib/include/resdata/rd_sum_index.hpp deleted file mode 100644 index 042b19ca6..000000000 --- a/lib/include/resdata/rd_sum_index.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef ERT_RD_SUM_INDEX_H -#define ERT_RD_SUM_INDEX_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rd_sum_index_struct rd_sum_index_type; - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/resdata/rd_sum_index.cpp b/lib/resdata/rd_sum_index.cpp deleted file mode 100644 index c14b2af27..000000000 --- a/lib/resdata/rd_sum_index.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -/* - This file contains all the internalized information from parsing a - SMSPEC file. In most cases the rd_sum object will contain a - rd_sum_index_type instance, and the end-user will not have direct - interaction with the rd_sum_index_type - but for instance when - working with an ensemble of identical summary results one can use a - shared rd_sum_index instance. -*/ - -struct rd_sum_index_type { - hash_type *well_var_index; /* Indexes for all well variables. */ - hash_type *well_completion_var_index; /* Indexes for completion indexes .*/ - hash_type *group_var_index; /* Indexes for group variables. */ - hash_type *field_var_index; /* Indexes for field variables. */ - hash_type *region_var_index; /* The stored index is an offset. */ - hash_type * - misc_var_index; /* Indexes for misceallous variables - typically date. */ - hash_type *block_var_index; /* Indexes for block variables. */ - - hash_type *unit_hash; /* Units for the various measurements. */ -}; From 493ce888c51a183569269573ece8bd6553ce97ca Mon Sep 17 00:00:00 2001 From: Eivind Jahren Date: Fri, 23 Aug 2024 13:48:47 +0200 Subject: [PATCH 4/5] Remove unused well_branch_collection_free__ --- lib/include/resdata/well/well_branch_collection.hpp | 1 - lib/resdata/well_branch_collection.cpp | 6 ------ 2 files changed, 7 deletions(-) diff --git a/lib/include/resdata/well/well_branch_collection.hpp b/lib/include/resdata/well/well_branch_collection.hpp index a4258da58..3ee45addb 100644 --- a/lib/include/resdata/well/well_branch_collection.hpp +++ b/lib/include/resdata/well/well_branch_collection.hpp @@ -15,7 +15,6 @@ typedef struct well_branch_collection_struct well_branch_collection_type; well_branch_collection_type *well_branch_collection_alloc(void); void well_branch_collection_free(well_branch_collection_type *branches); -void well_branch_collection_free__(void *arg); bool well_branch_collection_has_branch( const well_branch_collection_type *branches, int branch_id); int well_branch_collection_get_size( diff --git a/lib/resdata/well_branch_collection.cpp b/lib/resdata/well_branch_collection.cpp index f3a84e72c..fb5bef478 100644 --- a/lib/resdata/well_branch_collection.cpp +++ b/lib/resdata/well_branch_collection.cpp @@ -46,12 +46,6 @@ void well_branch_collection_free(well_branch_collection_type *branches) { delete branches; } -void well_branch_collection_free__(void *arg) { - well_branch_collection_type *branches = - well_branch_collection_safe_cast(arg); - well_branch_collection_free(branches); -} - int well_branch_collection_get_size( const well_branch_collection_type *branches) { return branches->__start_segments.size(); From 00726ff08432479f08e1e3a096b91ade1cdfd5cf Mon Sep 17 00:00:00 2001 From: Eivind Jahren Date: Fri, 23 Aug 2024 13:56:28 +0200 Subject: [PATCH 5/5] Remove unused c code in well_ts --- lib/include/resdata/well/well_ts.hpp | 4 ---- lib/resdata/well_ts.cpp | 18 ------------------ 2 files changed, 22 deletions(-) diff --git a/lib/include/resdata/well/well_ts.hpp b/lib/include/resdata/well/well_ts.hpp index 52c08a474..33ebcdc38 100644 --- a/lib/include/resdata/well/well_ts.hpp +++ b/lib/include/resdata/well/well_ts.hpp @@ -12,15 +12,11 @@ typedef struct well_ts_struct well_ts_type; void well_ts_free(well_ts_type *well_ts); void well_ts_add_well(well_ts_type *well_ts, well_state_type *well_state); well_ts_type *well_ts_alloc(const char *well_name); -void well_ts_free__(void *arg); -well_state_type *well_ts_get_state_from_sim_time(const well_ts_type *well_ts, - time_t sim_time); well_state_type *well_ts_get_state_from_report(const well_ts_type *well_ts, int report_nr); well_state_type *well_ts_iget_state(const well_ts_type *well_ts, int index); int well_ts_get_size(const well_ts_type *well_ts); const char *well_ts_get_name(const well_ts_type *well_ts); -well_state_type *well_ts_get_first_state(const well_ts_type *well_ts); well_state_type *well_ts_get_last_state(const well_ts_type *well_ts); #ifdef __cplusplus diff --git a/lib/resdata/well_ts.cpp b/lib/resdata/well_ts.cpp index a37df5a6a..731590413 100644 --- a/lib/resdata/well_ts.cpp +++ b/lib/resdata/well_ts.cpp @@ -244,17 +244,8 @@ void well_ts_free(well_ts_type *well_ts) { delete well_ts; } -void well_ts_free__(void *arg) { - well_ts_type *well_ts = well_ts_safe_cast(arg); - well_ts_free(well_ts); -} - int well_ts_get_size(const well_ts_type *well_ts) { return well_ts->ts.size(); } -well_state_type *well_ts_get_first_state(const well_ts_type *well_ts) { - return well_ts_iget_state(well_ts, 0); -} - well_state_type *well_ts_get_last_state(const well_ts_type *well_ts) { return well_ts_iget_state(well_ts, well_ts->ts.size() - 1); } @@ -273,12 +264,3 @@ well_state_type *well_ts_get_state_from_report(const well_ts_type *well_ts, else return well_ts_iget_state(well_ts, index); } - -well_state_type *well_ts_get_state_from_sim_time(const well_ts_type *well_ts, - time_t sim_time) { - int index = well_ts_get_index(well_ts, -1, sim_time, false); - if (index < 0) - return NULL; - else - return well_ts_iget_state(well_ts, index); -}