Ejemplo n.º 1
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;
  }
}
Ejemplo n.º 2
0
void sched_history_update( sched_history_type * sched_history, const sched_file_type * sched_file ) {
  
  sched_history_realloc( sched_history );
  sched_history_add_FIELD_group( sched_history );
  {
    int block_nr;
    stringlist_type * well_list  = stringlist_alloc_new();    
    stringlist_type * group_list = stringlist_alloc_new();

    for (block_nr = 0; block_nr < sched_file_get_num_restart_files( sched_file ); block_nr++) {
      sched_block_type * block = sched_file_iget_block( sched_file , block_nr );
      int kw_nr;
      int report_step = block_nr;

      time_t_vector_iset( sched_history->time , block_nr , sched_file_iget_block_end_time( sched_file , block_nr));
      for (kw_nr = 0; kw_nr < sched_block_get_size( block ); kw_nr++) {
        sched_kw_type * kw         = sched_block_iget_kw( block , kw_nr );
        sched_kw_type_enum kw_type = sched_kw_get_type( kw );

        switch( kw_type ) {
        case(WCONHIST):
          {
            const sched_kw_wconhist_type * wconhist = sched_kw_get_data( kw );
            sched_kw_wconhist_init_well_list( wconhist , well_list );
            int iw;
            for (iw = 0; iw < stringlist_get_size( well_list ); iw++) {
              const char * well_name           = stringlist_iget( well_list , iw );
              well_history_type * well_history = sched_history_get_well( sched_history , well_name );
              well_history_add_keyword( well_history , kw , report_step );
            }
          }
          sched_history_set_historical( sched_history , block_nr );
          break; 
        case(WCONPROD):    /* This is only added to turn the well OFF from WCONHIST behaviour.  It is currently not
                              possible to query the well for anything when it is in WCONPROD state. */

          { 
            const sched_kw_wconprod_type * wconprod = sched_kw_get_data( kw ); 
            sched_kw_wconprod_init_well_list( wconprod , well_list );
            int iw;
            for (iw = 0; iw < stringlist_get_size( well_list ); iw++) {
              const char * well_name           = stringlist_iget( well_list , iw );
              well_history_type * well_history = sched_history_get_well( sched_history , well_name );
              well_history_add_keyword( well_history , kw , report_step);
            }
          }
          bool_vector_iset_default( sched_history->historical , block_nr , false );
          break;
        case(WCONINJE):
          {
            const sched_kw_wconinje_type * wconinje = sched_kw_get_data( kw );
            sched_kw_wconinje_init_well_list( wconinje , well_list );
            int iw;
            for (iw = 0; iw < stringlist_get_size( well_list ); iw++) {
              const char * well_name           = stringlist_iget( well_list , iw );
              well_history_type * well_history = sched_history_get_well( sched_history , well_name );
              well_history_add_keyword( well_history , kw , report_step);
            }
            if (sched_kw_wconinje_historical( wconinje ))
              sched_history_set_historical( sched_history , block_nr );
          }
          break;
        case(WCONINJH):
          /* ... */
          sched_history_set_historical( sched_history , block_nr );
          break;
        case(WELSPECS):
          {
            const sched_kw_welspecs_type * welspecs = sched_kw_get_data( kw );
            sched_kw_welspecs_init_child_parent_list( welspecs , well_list , group_list );
            sched_history_add_wells( sched_history , welspecs , well_list );
            sched_history_add_groups_welspecs( sched_history , welspecs , report_step , well_list , group_list );
            for (int iw = 0; iw < stringlist_get_size( well_list ); iw++) {
              const char * well_name           = stringlist_iget( well_list , iw );
              well_history_type * well_history = sched_history_get_well( sched_history , well_name );
              well_history_add_keyword( well_history , kw , report_step);
            }
          }
          break;
        case(GRUPTREE):
          {
            const sched_kw_gruptree_type * gruptree = sched_kw_get_data( kw );
            stringlist_type * parent_group_list = group_list;
            stringlist_type * child_group_list  = well_list;

            sched_kw_gruptree_init_child_parent_list( gruptree , child_group_list , parent_group_list );
            sched_history_add_groups_gruptree( sched_history , gruptree , report_step , well_list , group_list );
          }
          break;
        default:
          /*   */
          break;
        }
      }
    }
    stringlist_free( well_list );
    stringlist_free( group_list );
  }
  sched_history_install_index( sched_history );
}