コード例 #1
0
ファイル: config_content.c プロジェクト: agchitu/ert
config_path_elm_type * config_content_add_path_elm( config_content_type * content , const char * path ) {
  const config_path_elm_type * current_path_elm;

  if (vector_get_size( content->path_elm_stack ) == 0)
    current_path_elm = NULL;
  else
    current_path_elm = vector_get_last_const(content->path_elm_stack);

  {
    config_path_elm_type * new_path_elm;

    {
      char * rel_path = NULL;
      config_root_path_type * invoke_path = config_content_get_invoke_path( content );
      if (path != NULL) {
        if (current_path_elm == NULL)
          rel_path = util_alloc_rel_path( config_root_path_get_abs_path(invoke_path) , path);
        else
          rel_path = config_path_elm_alloc_relpath( current_path_elm , path );
      }
      new_path_elm = config_path_elm_alloc( invoke_path , rel_path );
      util_safe_free( rel_path );
    }
    vector_append_owned_ref( content->path_elm_storage , new_path_elm , config_path_elm_free__);
    vector_append_ref( content->path_elm_stack , new_path_elm );
    return new_path_elm;
  }
}
コード例 #2
0
ファイル: ecl_sum_data.c プロジェクト: akva2/ResInsight
static void ecl_sum_data_update_end_info( ecl_sum_data_type * sum_data ) {
  const ecl_sum_tstep_type * last_ministep  = vector_get_last_const( sum_data->data );
   
  sum_data->last_ministep  = ecl_sum_tstep_get_ministep( last_ministep );
  sum_data->sim_length      = ecl_sum_tstep_get_sim_days( last_ministep );
  sum_data->sim_end         = ecl_sum_tstep_get_sim_time( last_ministep );
}
コード例 #3
0
ファイル: well_ts.c プロジェクト: JacobStoren/ert
static int well_ts_get_index__( const well_ts_type * well_ts , int report_step , time_t sim_time , bool use_report) {
  const int size = vector_get_size( well_ts->ts );
  if (size == 0)
    return 0;

  else {
    const well_node_type * first_node = vector_iget_const( well_ts->ts , 0 ); 
    const well_node_type * last_node  = vector_get_last_const( well_ts->ts ); 
    
    if (use_report) {
      if (report_step < first_node->report_nr)
        return -1;         // Before the start
      
      if (report_step >= last_node->report_nr)
        return size - 1;   // After end
    } else {
      if (sim_time < first_node->sim_time)
        return -1;         // Before the start
      
      if (sim_time >= last_node->sim_time)
        return size - 1;   // After end
    }
    
    // Binary search 
    {
      int lower_index  = 0;
      int upper_index  = size - 1;
      
      while (true) {
        int center_index = (lower_index + upper_index) / 2;
        const well_node_type * center_node = vector_iget_const( well_ts->ts , center_index );      
        double cmp;
        if (use_report)
          cmp = center_node->report_nr - report_step;
        else
          cmp = difftime( center_node->sim_time , sim_time );
        
        if (cmp > 0) {
          if ((center_index - lower_index) == 1)    // We found an interval of length 1
            return lower_index;
          else 
            upper_index = center_index;
          
        } else {
          
          if ((upper_index - center_index) == 1)    // We found an interval of length 1
            return center_index;
          else 
            lower_index = center_index;
        }
      }
    }
  }
}
コード例 #4
0
ファイル: well_ts.c プロジェクト: JacobStoren/ert
void well_ts_add_well( well_ts_type * well_ts , well_state_type * well_state ) {
  well_node_type * new_node = well_node_alloc( well_state );
  vector_append_owned_ref( well_ts->ts , new_node , well_node_free__ );

  if (vector_get_size( well_ts->ts ) > 1) {
    const well_node_type * last_node = vector_get_last_const(well_ts->ts );
    if (new_node->sim_time < last_node->sim_time) 
      // The new node is chronologically before the previous node;
      // i.e. we must sort the nodes in time. This should probably happen
      // quite seldom:
      vector_sort( well_ts->ts , well_node_time_cmp );
  }
}