示例#1
0
文件: block_obs.c 项目: jokva/ert
/**
   The input vectors i,j,k should contain offset zero values.
*/
block_obs_type * block_obs_alloc_complete(const char   * obs_key,
        block_obs_source_type source_type ,
        const stringlist_type * summary_keys ,
        const void * data_config ,
        const ecl_grid_type * grid ,
        int            size,
        const int    * i,
        const int    * j,
        const int    * k,
        const double * obs_value,
        const double * obs_std)
{
    block_obs_validate_ijk( grid , size , i,j,k);
    {
        block_obs_type * block_obs = block_obs_alloc( obs_key , data_config , grid );
        if (block_obs) {
            for (int l=0; l < size; l++) {

                if (source_type == SOURCE_SUMMARY) {
                    const char * sum_key = stringlist_iget( summary_keys , l );
                    block_obs_append_summary_obs( block_obs , i[l] , j[l] , k[l] , sum_key , obs_value[l] , obs_std[l]);
                } else
                    block_obs_append_field_obs( block_obs , i[l] , j[l] , k[l] , obs_value[l] , obs_std[l]);

            }
            return block_obs;
        } else {
            util_abort("%s: internal error - block_obs_alloc() returned NULL \n",__func__);
            return NULL;
        }
    }
}
示例#2
0
/**
   The input vectors i,j,k should contain offset zero values.
*/
block_obs_type * block_obs_alloc(const char   * obs_key,
                                 block_obs_source_type source_type , 
                                 const stringlist_type * summary_keys , 
                                 const void * data_config , 
                                 const ecl_grid_type * grid ,
                                 int            size,
                                 const int    * i,
                                 const int    * j,
                                 const int    * k,
                                 const double * obs_value,
                                 const double * obs_std)
{
  block_obs_validate_ijk( grid , size , i,j,k);
  
  {
    block_obs_type * block_obs = util_malloc(sizeof * block_obs);
    char           * sum_kw    = NULL;

    UTIL_TYPE_ID_INIT( block_obs , BLOCK_OBS_TYPE_ID );
    block_obs->obs_key         = util_alloc_string_copy(obs_key);
    block_obs->data_config     = data_config;
    block_obs->source_type     = source_type; 
    block_obs->size            = 0;
    block_obs->point_list      = NULL;
    block_obs->grid            = grid;
    block_obs_resize( block_obs , size );
    
    {
      for (int l=0; l < size; l++) {
        int active_index = ecl_grid_get_active_index3( block_obs->grid , i[l],j[l],k[l]);
        char * sum_key   = NULL;
        if (source_type == SOURCE_SUMMARY) 
          sum_key = stringlist_iget( summary_keys , l );
        
        block_obs->point_list[l] = point_obs_alloc(source_type , i[l] , j[l] , k[l] , active_index , sum_key , obs_value[l] , obs_std[l]);
      }
    }
    return block_obs;
  }
}