Пример #1
0
int ecl_sum_data_get_report_step_from_days(const ecl_sum_data_type * data , double sim_days) {
  if ((sim_days < data->days_start) || (sim_days > data->sim_length))
    return -1;
  else {
    int report_step = -1;

    double_vector_type * days_map = double_vector_alloc( 0 , 0 );
    int_vector_type    * report_map = int_vector_alloc( 0 , 0 );
    int i;

    for (i=1; i < int_vector_size( data->report_last_index ); i++) {
      int ministep_index = int_vector_iget( data->report_last_index , i );
      const ecl_sum_tstep_type * ministep = vector_iget_const( data->data , ministep_index );
      
      double_vector_iset( days_map , i , ecl_sum_tstep_get_sim_days( ministep ));
      int_vector_iset( report_map , i , ecl_sum_tstep_get_report( ministep ));
    }
    
    {
      /** Hmmmm - double == comparison ... */
      int index = double_vector_index_sorted( days_map , sim_days );
      
      if (index >= 0)
        report_step = int_vector_iget( report_map , index );
    }
    
    int_vector_free( report_map );
    double_vector_free( days_map );
    return report_step;
  }
}
Пример #2
0
static void ecl_nnc_geometry_add_pairs( const ecl_nnc_geometry_type * nnc_geo , const ecl_grid_type * grid ) {
  int lgr_nr1 = ecl_grid_get_lgr_nr( grid );
  const ecl_grid_type * global_grid = ecl_grid_get_global_grid( grid );

  if (!global_grid)
    global_grid = grid;


  for (int global_index1 = 0; global_index1 < ecl_grid_get_global_size( grid ); global_index1++) {
    const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1( grid , global_index1 );
    if (!nnc_info)
      continue;

    for (int lgr_index2 = 0; lgr_index2 < nnc_info_get_size( nnc_info ); lgr_index2++) {
      const nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index2 );
      const int_vector_type * grid2_index_list = nnc_vector_get_grid_index_list( nnc_vector );
      const int_vector_type * nnc_index_list = nnc_vector_get_nnc_index_list( nnc_vector );
      int lgr_nr2 = nnc_vector_get_lgr_nr( nnc_vector );

      for (int index2 = 0; index2 < nnc_vector_get_size( nnc_vector ); index2++) {
        ecl_nnc_pair_type pair;
        pair.grid_nr1 = lgr_nr1;
        pair.global_index1 = global_index1;
        pair.grid_nr2 = lgr_nr2;
        pair.global_index2 = int_vector_iget( grid2_index_list , index2 );
        pair.input_index = int_vector_iget( nnc_index_list, index2 );
        struct_vector_append( nnc_geo->data , &pair);
      }
    }
  }
}
Пример #3
0
int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type * data , time_t sim_time) {
  if ((sim_time < data->data_start_time) || (sim_time > data->sim_end))
    return -1;

  {
    int report_step = -1;

    time_t_vector_type * time_map = time_t_vector_alloc( 0 , 0 );
    int_vector_type    * report_map = int_vector_alloc( 0 , 0 );
    int i;

    for (i=1; i < int_vector_size( data->report_last_index ); i++) {
      int ministep_index = int_vector_iget( data->report_last_index , i );
      const ecl_sum_tstep_type * ministep = vector_iget_const( data->data , ministep_index );
      
      time_t_vector_iset( time_map , i , ecl_sum_tstep_get_sim_time( ministep ));
      int_vector_iset( report_map , i , ecl_sum_tstep_get_report( ministep ));
      
    }
    
    {
      int index = time_t_vector_index_sorted( time_map , sim_time );
      
      if (index >= 0)
        report_step = int_vector_iget( report_map , index );
    }
    
    int_vector_free( report_map );
    time_t_vector_free( time_map );
    return report_step;
  }
}
Пример #4
0
void fault_block_layer_scan_layer( fault_block_layer_type * fault_layer , layer_type * layer) {
  int i,j;
  int_vector_type * i_list = int_vector_alloc(0,0);
  int_vector_type * j_list = int_vector_alloc(0,0);

  for (j = 0; j < layer_get_ny( layer ); j++) {
    for (i = 0; i < layer_get_nx( layer); i++) {
      int cell_value = layer_iget_cell_value( layer , i , j );
      if (cell_value != 0) {
        layer_trace_block_content( layer , true , i , j , cell_value , i_list , j_list );
        {
          int c;
          int block_id = fault_block_layer_get_next_id( fault_layer );
          fault_block_type * fault_block = fault_block_layer_add_block( fault_layer , block_id );
          for (c=0; c < int_vector_size( i_list ); c++)
            fault_block_add_cell( fault_block , int_vector_iget( i_list , c ), int_vector_iget( j_list , c ));

        }
      }
    }
  }

  int_vector_free( i_list );
  int_vector_free( j_list );
}
Пример #5
0
int main(int argc , char ** argv) {
    int lgr_nr = 100;
    nnc_vector_type * vector = nnc_vector_alloc( lgr_nr );

    test_assert_true( nnc_vector_is_instance( vector ));
    test_assert_int_equal( lgr_nr , nnc_vector_get_lgr_nr( vector ));

    nnc_vector_add_nnc( vector , 100 );
    nnc_vector_add_nnc( vector , 200 );
    nnc_vector_add_nnc( vector , 300 );

    nnc_vector_add_nnc( vector , 100 );
    nnc_vector_add_nnc( vector , 200 );
    nnc_vector_add_nnc( vector , 300 );


    {
        const int_vector_type * index_list = nnc_vector_get_index_list( vector );

        test_assert_int_equal( 3 , int_vector_size( index_list ));
        test_assert_int_equal( 100 , int_vector_iget( index_list , 0 ));
        test_assert_int_equal( 200 , int_vector_iget( index_list , 1 ));
        test_assert_int_equal( 300 , int_vector_iget( index_list , 2 ));
    }

    nnc_vector_free( vector );
    exit(0);
}
Пример #6
0
int main( int argc , char ** argv) {
  const char * egrid_file = argv[1];

  ecl_grid_type * grid = ecl_grid_alloc( egrid_file );
  ecl_file_type * gfile = ecl_file_open( egrid_file , 0 );
  const ecl_kw_type * nnc1_kw = ecl_file_iget_named_kw( gfile , "NNC1" ,0 );
  const ecl_kw_type * nnc2_kw = ecl_file_iget_named_kw( gfile , "NNC2" ,0 );
  const int_vector_type * index_list = ecl_grid_get_nnc_index_list( grid );
  
  {
    int_vector_type * nnc = int_vector_alloc(0,0);
    
    int_vector_set_many( nnc , 0 , ecl_kw_get_ptr( nnc1_kw ) , ecl_kw_get_size( nnc1_kw ));
    int_vector_append_many( nnc , ecl_kw_get_ptr( nnc2_kw ) , ecl_kw_get_size( nnc2_kw ));
    int_vector_select_unique( nnc );
    test_assert_int_equal( int_vector_size( index_list ) , int_vector_size( nnc ));
    
    {
      int i;
      for (i=0; i < int_vector_size( nnc ); i++)
        test_assert_int_equal( int_vector_iget( nnc , i ) - 1 , int_vector_iget(index_list , i ));
    }
    int_vector_free( nnc );
  }
  
  ecl_file_close( gfile );
  ecl_grid_free( grid );

  exit(0);
}
Пример #7
0
void test_resize() {
  int i;
  int def = 77;
  int_vector_type * vec = int_vector_alloc(0,def);
  int_vector_resize( vec , 10 );
  test_assert_int_equal( int_vector_size( vec ) , 10 );
  for (i=0; i < 10; i++)
    test_assert_int_equal( int_vector_iget( vec , i ) , def );
  
  int_vector_iset_block( vec , 5 , 5 , 5 );
  for (i=5; i < 10; i++)
    test_assert_int_equal( int_vector_iget( vec , i ) , 5 );

  int_vector_resize( vec , 5 );
  test_assert_int_equal( int_vector_size( vec ) , 5 );
  for (i=0; i < 5; i++)
    test_assert_int_equal( int_vector_iget( vec , i ) , def );

  int_vector_resize( vec , 10 );
  test_assert_int_equal( int_vector_size( vec ) , 10 );
  for (i=0; i < 10; i++)
    test_assert_int_equal( int_vector_iget( vec , i ) , def );

  int_vector_free( vec );
}
Пример #8
0
static int  ecl_nnc_export__( const ecl_grid_type * grid , int lgr_index1 , const ecl_file_type * init_file , ecl_nnc_type * nnc_data, int * nnc_offset) {
  int nnc_index = *nnc_offset;
  int lgr_nr1 = ecl_grid_get_lgr_nr( grid );
  int global_index1;
  int valid_trans = 0 ;
  const ecl_grid_type * global_grid = ecl_grid_get_global_grid( grid );

  if (!global_grid)
    global_grid = grid;


  for (global_index1 = 0; global_index1 < ecl_grid_get_global_size( grid ); global_index1++) {
    const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1( grid , global_index1 );
    if (nnc_info) {
      int lgr_index2;
      for (lgr_index2=0; lgr_index2 < nnc_info_get_size( nnc_info ); lgr_index2++) {
        const nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index2 );
        const int_vector_type * grid2_index_list = nnc_vector_get_grid_index_list( nnc_vector );
        const int_vector_type * nnc_index_list = nnc_vector_get_nnc_index_list( nnc_vector );
        int lgr_nr2 = nnc_vector_get_lgr_nr( nnc_vector );
        const ecl_kw_type * tran_kw = ecl_nnc_export_get_tranx_kw(global_grid  , init_file , lgr_nr1 , lgr_nr2 );

        int index2;
        ecl_nnc_type nnc;

        nnc.grid_nr1 = lgr_nr1;
        nnc.grid_nr2 = lgr_nr2;
        nnc.global_index1 = global_index1;

        for (index2 = 0; index2 < nnc_vector_get_size( nnc_vector ); index2++) {
          nnc.global_index2 = int_vector_iget( grid2_index_list , index2 );
          nnc.input_index = int_vector_iget( nnc_index_list, index2 );
          if(tran_kw) {
            nnc.trans = ecl_kw_iget_as_double(tran_kw, nnc.input_index);
            valid_trans++;
          }else{
            nnc.trans = ERT_ECL_DEFAULT_NNC_TRANS;
          }

          nnc_data[nnc_index] = nnc;
          nnc_index++;
        }
      }
    }
  }
  *nnc_offset = nnc_index;
  return valid_trans;
}
Пример #9
0
/**
   This function will load an active map from the enkf_fs filesystem.
*/
void gen_data_config_load_active( gen_data_config_type * config , int report_step , bool force_load) {
  if (config->fs == NULL)
    return;                /* This is used as a GEN_PARAM instance - and the loading of mask is not an option. */
  
  
  pthread_mutex_lock( &config->update_lock );
  {
    if ( force_load || (int_vector_iget( config->data_size_vector , report_step ) > 0)) {
      if (config->active_report_step != report_step) {
        char * filename = util_alloc_sprintf("%s_active" , config->key );
        FILE * stream   = enkf_fs_open_excase_tstep_file( config->fs , filename , report_step);

        if (stream != NULL) {
          bool_vector_fread( config->active_mask , stream );
          fclose( stream );
        } else 
          fprintf(stderr,"** Warning: could not find file:%s \n",filename);

        free( filename );
      }
    }
    config->active_report_step = report_step;
  }
  pthread_mutex_unlock( &config->update_lock );
}
Пример #10
0
static int file_map_find_kw_value( const file_map_type * file_map , const char * kw , const void * value) {
  int global_index = -1;
  if ( file_map_has_kw( file_map , kw)) {
    const int_vector_type * index_list = hash_get( file_map->kw_index , kw );
    int index = 0;
    while (index < int_vector_size( index_list )) {
      const ecl_kw_type * ecl_kw = file_map_iget_kw( file_map , int_vector_iget( index_list , index ));
      if (ecl_kw_data_equal( ecl_kw , value )) {
        global_index = int_vector_iget( index_list , index );
        break;
      }
      index++;
    }
  }
  return global_index;
}
Пример #11
0
void test_coarse_cell(const ecl_grid_type * grid , ecl_coarse_cell_type * cell ) {
  const int_vector_type * global_index_list = ecl_coarse_cell_get_index_vector(cell );
  const int * ijk = ecl_coarse_cell_get_box_ptr( cell );
  int c;
  int prev_active = 0;

  for (c=0; c < ecl_coarse_cell_get_size( cell ); c++) {
    int gi = int_vector_iget( global_index_list , c );
    int i,j,k;

    /* The coordinates are right */
    ecl_grid_get_ijk1( grid , gi , &i , &j , &k);
    if ((i < ijk[0]) || (i > ijk[1]))
      test_error_exit("i:%d not inside range [%d,%d] \n",i , ijk[0] , ijk[1]); 

    if ((j < ijk[2]) || (j > ijk[3]))
      test_error_exit("j:%d not inside range [%d,%d] \n",j , ijk[2] , ijk[3]); 

    if ((k < ijk[4]) || (k > ijk[5]))
      test_error_exit("k:%d not inside range [%d,%d] \n",k , ijk[4] , ijk[4]); 

    if (c == 0)
      prev_active = ecl_grid_get_active_index1( grid , gi );
    else {
      /* All the cells have the same active value */
      int this_active = ecl_grid_get_active_index1( grid , gi );
      test_assert_int_equal( prev_active , this_active );
      prev_active = this_active;
    }
  }
}
Пример #12
0
run_arg_type * ert_run_context_iens_get_arg( const ert_run_context_type * context , int iens) {
  int index = int_vector_iget( context->iens_map , iens );
  if (index >= 0)
    return vector_iget( context->run_args , index );
  else
    return NULL;
}
Пример #13
0
void obs_vector_measure(const obs_vector_type * obs_vector , 
                        enkf_fs_type * fs , 
                        state_enum state , 
                        int report_step , 
                        const int_vector_type * ens_active_list , 
                        meas_data_type * meas_data , 
                        const active_list_type * active_list) {
  
  void * obs_node = vector_iget( obs_vector->nodes , report_step );
  if ( obs_node != NULL ) {
    enkf_node_type * enkf_node = enkf_node_deep_alloc( obs_vector->config_node );

    node_id_type node_id = { .report_step = report_step , 
                             .state       = state , 
                             .iens        = 0 };

    for (int active_iens_index =0; active_iens_index < int_vector_size( ens_active_list ); active_iens_index++) {
      node_id.iens = int_vector_iget( ens_active_list , active_iens_index );
      
      enkf_node_load(enkf_node , fs , node_id);
      node_id.iens = active_iens_index;
      obs_vector->measure(obs_node , enkf_node_value_ptr(enkf_node) , node_id , meas_data , active_list);
    }

    enkf_node_free( enkf_node );
  }
}
Пример #14
0
void test_trace_edge( const ecl_grid_type * grid) {
  const int k = 1;
  fault_block_layer_type * layer = fault_block_layer_alloc( grid , k );
  double_vector_type * x_list = double_vector_alloc( 0,0);
  double_vector_type * y_list = double_vector_alloc( 0,0);
  fault_block_type * block = fault_block_layer_safe_get_block( layer , 99);
  int_vector_type * cell_list = int_vector_alloc(0,0);
    
  test_assert_false( fault_block_trace_edge( block , x_list , y_list , cell_list));
  fault_block_add_cell( block , 0,0);
  test_assert_true( fault_block_trace_edge( block , x_list , y_list , cell_list));
  test_assert_int_equal( 4 , double_vector_size( x_list ));
  test_assert_int_equal( 4 , double_vector_size( y_list ));
  
  test_assert_double_equal( 0 , double_vector_iget( x_list , 0 ));
  test_assert_double_equal( 1 , double_vector_iget( x_list , 1 ));
  test_assert_double_equal( 1 , double_vector_iget( x_list , 2 ));
  test_assert_double_equal( 0 , double_vector_iget( x_list , 3 ));
  
  test_assert_double_equal( 0 , double_vector_iget( y_list , 0 ));
  test_assert_double_equal( 0 , double_vector_iget( y_list , 1 ));
  test_assert_double_equal( 1 , double_vector_iget( y_list , 2 ));
  test_assert_double_equal( 1 , double_vector_iget( y_list , 3 ));

  test_assert_int_equal( 1 , int_vector_size( cell_list ));
  test_assert_int_equal( 0 , int_vector_iget( cell_list , 0));

  int_vector_free( cell_list );
  double_vector_free( x_list );
  double_vector_free( y_list );
}
Пример #15
0
static bool_vector_type * alloc_mask( const int_vector_type * active_list ) {
  bool_vector_type * mask = bool_vector_alloc( 0 , false );
  int i;
  for (i=0; i < int_vector_size( active_list ); i++) 
    bool_vector_iset( mask , int_vector_iget( active_list , i) , true );

  return mask;
}
Пример #16
0
void test_active_index_list() {
  int default_value = -1;
  bool_vector_type * mask = bool_vector_alloc(0 , false);

  bool_vector_iset(mask , 10, true);
  bool_vector_iset(mask , 15, true);
  bool_vector_iset(mask , 20, true);

  {
    int_vector_type * active_index_list = bool_vector_alloc_active_index_list(mask , default_value);

    test_assert_int_equal( default_value , int_vector_get_default(active_index_list));
    test_assert_int_equal( 21 , int_vector_size( active_index_list ));

    test_assert_int_equal( default_value , int_vector_iget( active_index_list , 0));
    test_assert_int_equal( default_value , int_vector_iget( active_index_list , 1));
    test_assert_int_equal( default_value , int_vector_iget( active_index_list , 12));
    test_assert_int_equal( default_value , int_vector_iget( active_index_list , 19));

    test_assert_int_equal( 0 , int_vector_iget( active_index_list , 10));
    test_assert_int_equal( 1 , int_vector_iget( active_index_list , 15));
    test_assert_int_equal( 2 , int_vector_iget( active_index_list , 20));


    int_vector_free( active_index_list);
  }
  bool_vector_free(mask);
}
Пример #17
0
void vector_permute(vector_type * vector , const int_vector_type * perm_vector) {
  node_data_type ** new_data = (node_data_type**)util_calloc( vector->size , sizeof * new_data );
  for (int index = 0; index < vector->size; index++) {
    int perm_index = int_vector_iget( perm_vector , index );
    new_data[index] = vector->data[ perm_index ];
  }
  free(vector->data);
  vector->data = new_data;
}
Пример #18
0
bool field_config_parse_user_key__( const char * index_key , int *i , int *j , int *k) {
    int      length;
    {
        int_vector_type * indices = string_util_alloc_value_list( index_key );
        length = int_vector_size( indices );

        if (length == 3) {
            *i = int_vector_iget( indices , 0) - 1;
            *j = int_vector_iget( indices , 1) - 1;
            *k = int_vector_iget( indices , 2) - 1;
        }

        int_vector_free( indices );
    }
    if (length == 3)
        return true;
    else
        return false;
}
Пример #19
0
void test_div() {
  int_vector_type * int_vector = int_vector_alloc( 0 , 100);
  int_vector_iset( int_vector , 10 , 100 );
  int_vector_div( int_vector , 10 );
  {
    int i;
    for (i=0; i < int_vector_size( int_vector ); i++) 
      test_assert_int_equal( 10 , int_vector_iget( int_vector , i ));
  }
}
Пример #20
0
const ecl_rft_cell_type * ecl_rft_node_iget_cell_sorted( ecl_rft_node_type * rft_node , int index) {
  if (ecl_rft_node_is_RFT( rft_node ))
    return ecl_rft_node_iget_cell( rft_node , index );
  else {
    if (!rft_node->sort_perm_in_sync)
      ecl_rft_node_create_sort_perm( rft_node );

    return vector_iget_const( rft_node->cells , int_vector_iget( rft_node->sort_perm , index ));
  }
}
Пример #21
0
void test_mask() {
  bool_vector_type * mask = bool_vector_alloc(0 , false);

  bool_vector_iset(mask , 10, true);
  bool_vector_iset(mask , 15, true);
  bool_vector_iset(mask , 20, true);

  {
    int_vector_type * index_list = bool_vector_alloc_active_list( mask );

    test_assert_int_equal( 3 , int_vector_size( index_list ));
    test_assert_int_equal( 10 , int_vector_iget( index_list , 0 ));
    test_assert_int_equal( 15 , int_vector_iget( index_list , 1 ));
    test_assert_int_equal( 20 , int_vector_iget( index_list , 2 ));

    int_vector_free( index_list );
  }
  bool_vector_free( mask );
}
Пример #22
0
const int_vector_type * nnc_info_get_index_list(const nnc_info_type * nnc_info, int lgr_nr) { 
  int_vector_type * ret = NULL;
  if (int_vector_size(nnc_info->lgr_index_map) > lgr_nr) {
    int lgr_index = int_vector_iget(nnc_info->lgr_index_map, lgr_nr); 
    if (-1 != lgr_index) {
      ret = vector_iget(nnc_info->lgr_list, lgr_index); 
    }
  }
  return ret;
}
Пример #23
0
void gen_data_config_update_active(gen_data_config_type * config, int report_step , const bool_vector_type * data_mask) {
  pthread_mutex_lock( &config->update_lock );
  {
    if ( int_vector_iget( config->data_size_vector , report_step ) > 0) {
      if (config->active_report_step != report_step) {
        /* This is the first ensemeble member loading for this
           particular report_step. */
        bool_vector_reset( config->active_mask );
        bool_vector_iset( config->active_mask , int_vector_iget( config->data_size_vector , report_step ) - 1 , true );
        config->mask_modified = true;
      }
      
      {
        int i;
        for (i=0; i < bool_vector_size( data_mask ); i++) {
          if (!bool_vector_iget( data_mask , i )) {
            bool_vector_iset( config->active_mask , i , false );
            config->mask_modified = true;
          }
        }
      } 
      
      if (config->mask_modified) {
        /**
           The global mask has been modified after the last load;
           i.e. we update the on-disk representation.
        */
        char * filename = util_alloc_sprintf("%s_active" , config->key );
        FILE * stream   = enkf_fs_open_case_tstep_file( config->write_fs , filename , report_step , "w");
        
        bool_vector_fwrite( config->active_mask , stream );

        fclose( stream );
        free( filename );
        config->mask_modified = false;
      }
    }
    config->active_report_step = report_step;
  }
  pthread_mutex_unlock( &config->update_lock );
}
Пример #24
0
bool string_util_update_active_mask( const char * range_string , bool_vector_type * active_mask) {
  int i;
  int_vector_type * sscanf_active = string_util_sscanf_alloc_active_list( range_string );
  if (sscanf_active) {
    for (i=0; i < int_vector_size( sscanf_active ); i++)
      bool_vector_iset( active_mask , int_vector_iget(sscanf_active , i) , true );
    
    int_vector_free( sscanf_active );
    return true;
  } else
    return false;
}
Пример #25
0
void test_memcpy_from_data() {
  int_vector_type * int_vector = int_vector_alloc( 10 , 77 );
  int data[5] = {1,2,3,4,5};

  int_vector_memcpy_from_data( int_vector , data , 5 );
  test_assert_int_equal( 5 , int_vector_size( int_vector ));

  for (int i=0; i < int_vector_size( int_vector ); i++) 
    test_assert_int_equal( i + 1 , int_vector_iget( int_vector , i ));
  
  int_vector_free( int_vector );
}
Пример #26
0
void test_alloc() {
  const int size = 100;
  const int default_value = 77;
  int_vector_type * v = int_vector_alloc(size , default_value);

  test_assert_int_equal(size , int_vector_size(v));
  for (int i=0; i < size; i++)
    test_assert_int_equal( default_value , int_vector_iget( v , i));


  int_vector_free( v);
}
Пример #27
0
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 );
  }
}
Пример #28
0
void test_iset_block() {
  int_vector_type * vec = int_vector_alloc(0,0);

  int_vector_iset_block( vec , 10 , 10 , 77 );
  test_assert_int_equal( int_vector_size( vec ) , 20 );
  {
    int i; 
    for (i=10; i < 20; i++)
      test_assert_int_equal( int_vector_iget( vec , i ) , 77 );
  }
  int_vector_iset_block( vec , 10 , 0 , 177 );
  test_assert_int_equal( int_vector_iget( vec , 10 ) , 77 );

  int_vector_iset_block( vec , 10 , -11 , 66 );
  {
    int i; 
    for (i=0; i <= 10; i++)
      test_assert_int_equal( int_vector_iget( vec , i ) , 66 );
  }
  int_vector_free( vec );
}
Пример #29
0
void test_idel_insert() {
  int_vector_type * vec = int_vector_alloc(0,0);

  int_vector_append(vec , 1 );
  int_vector_append(vec , 2 );
  int_vector_append(vec , 2 );
  int_vector_append(vec , 3 );

  int_vector_fprintf(vec , stdout , "Vec0" , "%2d");
  int_vector_idel(vec , 1 );
  int_vector_fprintf(vec , stdout , "Vec1" , "%2d");
  int_vector_idel(vec , 1 );
  int_vector_fprintf(vec , stdout , "Vec2" , "%2d");

  test_assert_int_equal( 2 , int_vector_size( vec ));
  test_assert_int_equal( 1 , int_vector_iget( vec , 0 ));
  test_assert_int_equal( 3 , int_vector_iget( vec , 1 ));

  int_vector_insert(vec , 1 , 2 );
  int_vector_insert(vec , 1 , 2 );
  test_assert_int_equal( 4 , int_vector_size( vec ));
  test_assert_int_equal( 1 , int_vector_iget( vec , 0 ));
  test_assert_int_equal( 2 , int_vector_iget( vec , 1 ));
  test_assert_int_equal( 2 , int_vector_iget( vec , 2 ));
  test_assert_int_equal( 3 , int_vector_iget( vec , 3 ));

  int_vector_free( vec );
}
Пример #30
0
static int ecl_rft_file_get_node_index_time_rft( const ecl_rft_file_type * rft_file , const char * well , time_t recording_time) {
  int global_index = -1;
  if (hash_has_key( rft_file->well_index , well)) {
    const int_vector_type * index_vector = hash_get(rft_file->well_index , well);
    int well_index = 0;
    while (true) {
      if (well_index == int_vector_size( index_vector ))
        break;

      {
        const ecl_rft_node_type * node = ecl_rft_file_iget_node( rft_file , int_vector_iget( index_vector , well_index ));
        if (ecl_rft_node_get_date( node ) == recording_time) {
          global_index = int_vector_iget( index_vector , well_index );
          break;
        }
      }

      well_index++;
    }
  }
  return global_index;
}