static void ecl_sum_data_clear_index( ecl_sum_data_type * data ) { int_vector_reset( data->report_first_index); int_vector_reset( data->report_last_index); data->first_report_step = 1024 * 1024; data->last_report_step = -1024 * 1024; data->days_start = 0; data->data_start_time = -1; data->sim_end = -1; data->sim_length = -1; data->first_ministep = -1; data->last_ministep = -1; data->index_valid = false; }
bool int_vector_init_range(int_vector_type * vector , int min_value , int max_value , int delta) { if (max_value >= min_value) { int current_value = min_value; int_vector_reset( vector ); while (current_value < max_value) { int_vector_append( vector , current_value ); current_value += delta; } int_vector_append( vector , max_value ); return true; } else return false; }
bool layer_trace_block_content( layer_type * layer , bool erase , int start_i , int start_j , int value , int_vector_type * i_list, int_vector_type * j_list) { bool start_tracing = false; int g = layer_get_global_cell_index( layer , start_i , start_j); cell_type * cell = &layer->data[g]; if ((value == 0) && (cell->cell_value != 0)) start_tracing = true; else if ((cell->cell_value == value) && (cell->cell_value != 0)) start_tracing = true; if (start_tracing) { bool * visited = layer_alloc_visited_mask( layer ); value = cell->cell_value; int_vector_reset( i_list ); int_vector_reset( j_list ); layer_trace_block_content__(layer , erase , start_i , start_j , value , visited , i_list , j_list ); free( visited ); return true; } else return false; }
void state_map_fread( state_map_type * map , const char * filename) { pthread_rwlock_wrlock( &map->rw_lock ); { if (util_file_exists( filename )) { FILE * stream = util_fopen( filename , "r"); if (stream) { int_vector_fread( map->state , stream ); fclose( stream ); } else util_abort("%s: failed to open:%s for reading \n",__func__ , filename ); } else int_vector_reset( map->state ); } pthread_rwlock_unlock( &map->rw_lock ); }
void int_vector_range_fill(int_vector_type * vector , int limit1 , int delta , int limit2) { int current_value = limit1; if (delta == 0) util_abort("%s: sorry can not have delta == 0 \n",__func__); int_vector_reset( vector ); while (true) { int_vector_append( vector , current_value ); current_value += delta; if (delta > 0 && current_value > limit2) break; if (delta < 0 && current_value < limit2) break; } }
bool layer_trace_block_edge( const layer_type * layer , int start_i , int start_j , int value , struct_vector_type * corner_list , int_vector_type * cell_list) { int g = layer_get_global_cell_index( layer , start_i , start_j); cell_type * cell = &layer->data[g]; if ((cell->cell_value == value)) { int i = start_i; int j = start_j; if (layer_find_edge( layer , &i , &j , value)) { int_point2d_type start_corner; g = layer_get_global_cell_index( layer , i , j); cell = &layer->data[g]; start_corner.i = i; start_corner.j = j; struct_vector_reset( corner_list ); int_vector_reset( cell_list ); if (cell->edges[BOTTOM_EDGE] == value) { point_shift( &start_corner , 0 , 0 ); layer_trace_block_edge__(layer , start_corner , i , j , value , BOTTOM_EDGE , corner_list , cell_list); } else if (cell->edges[RIGHT_EDGE] == value) { point_shift( &start_corner , 1 , 0 ); layer_trace_block_edge__(layer , start_corner , i , j , value , RIGHT_EDGE , corner_list , cell_list); } else if (cell->edges[TOP_EDGE] == -value) { point_shift( &start_corner , 1 , 1 ); layer_trace_block_edge__(layer , start_corner , i , j , value , TOP_EDGE , corner_list , cell_list); } else if (cell->edges[LEFT_EDGE] == -value) { point_shift( &start_corner , 0 , 1 ); layer_trace_block_edge__(layer , start_corner , i , j , value , LEFT_EDGE , corner_list , cell_list); } else util_abort("%s: what the f**k - internal error \n",__func__); int_vector_select_unique( cell_list ); return true; } } return false; }
void int_vector_select_unique(int_vector_type * vector) { int_vector_assert_writable( vector ); if (vector->size > 0) { int_vector_type * copy = int_vector_alloc_copy( vector ); int_vector_sort( copy ); int_vector_reset( vector ); { int i; int previous_value = int_vector_iget( copy , 0); int_vector_append( vector , previous_value); for (i=1; i < copy->size; i++) { int value = int_vector_iget( copy , i ); if (value != previous_value) int_vector_append( vector , value); previous_value = value; } } int_vector_free( copy ); } }
bool string_util_update_active_list( const char * range_string , int_vector_type * active_list ) { int_vector_sort( active_list ); { bool_vector_type * mask = alloc_mask( active_list ); bool valid = false; if (string_util_update_active_mask( range_string , mask )) { int_vector_reset( active_list ); { int i; for (i=0; i < bool_vector_size(mask); i++) { bool active = bool_vector_iget( mask , i ); if (active) int_vector_append( active_list , i ); } } valid = true; } bool_vector_free( mask ); return valid; } }
bool string_util_init_value_list( const char * range_string , int_vector_type * value_list ) { int_vector_reset( value_list ); return string_util_update_value_list( range_string , value_list ); }
bool string_util_init_active_list( const char * range_string , int_vector_type * active_list ) { int_vector_reset( active_list ); return string_util_update_active_list( range_string , active_list ); }
void int_vector_reset__(void * __vector) { int_vector_type * vector = int_vector_safe_cast( __vector ); int_vector_reset( vector ); }
void int_vector_free_data(int_vector_type * vector) { int_vector_reset(vector); int_vector_realloc_data__(vector , 0); }
void int_vector_memcpy( int_vector_type * target, const int_vector_type * src ) { int_vector_reset( target ); target->default_value = src->default_value; int_vector_memcpy_data_block( target , src , 0 , 0 , src->size ); }
void int_vector_memcpy_from_data( int_vector_type * target , const int * src , int src_size ) { int_vector_reset( target ); int_vector_iset( target , src_size - 1 , 0 ); memcpy( target->data , src , src_size * sizeof * target->data ); }
void gen_data_config_set_active_report_steps_from_string( gen_data_config_type *config , const char * range_string) { if (config->dynamic) { int_vector_reset( config->active_report_steps ); string_util_update_active_list(range_string , config->active_report_steps ); } }