Ejemplo n.º 1
0
bool field_config_ijk_active(const field_config_type * config , int i , int j , int k) {
    if (ecl_grid_ijk_valid(config->grid , i,j,k)) {
        int active_index = ecl_grid_get_active_index3( config->grid , i , j , k);

        if (active_index >= 0)
            return true;
        else
            return false;
    } else
        return false;
}
Ejemplo n.º 2
0
static void block_obs_validate_ijk( const ecl_grid_type * grid , int size, const int * i , const int * j , const int * k) {
  int l;
  for (l = 0; l < size; l++) {
    if (ecl_grid_ijk_valid(grid , i[l] , j[l] , k[l])) {
      int active_index = ecl_grid_get_active_index3( grid , i[l] , j[l] , k[l]);
      if (active_index < 0) 
        util_abort("%s: sorry: cell:(%d,%d,%d) is not active - can not observe it. \n",__func__ , i[l]+1 , j[l]+1 , k[l]+1);
      
    } else
      util_abort("%s: sorry: cell (%d,%d,%d) is outside valid range:  \n",__func__ , i[l]+1 , j[l]+1 , k[l]+1);
  }
}
Ejemplo n.º 3
0
 ecl_box::ecl_box(const ecl_grid_type * grid, int i1, int i2, int j1, int j2, int k1, int k2) :
   grid(grid),
   i1(std::min(i1,i2)),
   i2(std::max(i1,i2)),
   j1(std::min(j1,j2)),
   j2(std::max(j1,j2)),
   k1(std::min(k1,k2)),
   k2(std::max(k1,k2))
 {
   for (int k=this->k1; k <= this->k2; k++)
     for (int j=this->j1; j <= this->j2; j++)
       for (int i=this->i1; i <= this->i2; i++) {
         int active_index = ecl_grid_get_active_index3(this->grid, i, j , k);
         if (active_index >= 0)
           this->active_index_list.push_back(active_index);
         this->global_index_list.push_back(ecl_grid_get_global_index3(this->grid, i, j, k));
       }
 }
Ejemplo n.º 4
0
void block_obs_user_get(const block_obs_type * block_obs , const char * index_key , double *value , double * std, bool * valid) {
  int      i,j,k;

  *valid = false;
  if (field_config_parse_user_key__( index_key , &i , &j , &k)) {
    int active_index = ecl_grid_get_active_index3(block_obs->grid , i,j,k);
    int l = 0;
    /* iterating through all the cells the observation is observing. */

    while (!(*valid) && l < block_obs->size) {
      const point_obs_type * point_obs = block_obs->point_list[l];
      if (point_obs->active_index == active_index) {
        *value = point_obs->value;
        *std   = point_obs->std;
        *valid = true;
      }
      l++;
    }
  }
}
Ejemplo n.º 5
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;
  }
}
Ejemplo n.º 6
0
inline int field_config_active_index(const field_config_type * config , int i , int j , int k) {
    return ecl_grid_get_active_index3( config->grid , i,j,k);
}
Ejemplo n.º 7
0
void rms_export_roff_from_keyword(const char *filename, ecl_grid_type *ecl_grid, 
    ecl_kw_type **ecl_kw, int size) {
  
  rms_file_type *rms_file;
  rms_tagkey_type *data_key;
  int nx, ny, nz, active_size;
  int i, j, k;
  int global_size;
  int n;
    
  ecl_grid_get_dims(ecl_grid, &nx, &ny, &nz, &active_size);
  global_size = ecl_grid_get_global_size(ecl_grid);
  
  rms_file = rms_file_alloc(filename, false);
  rms_file_fopen_w(rms_file);

  rms_file_init_fwrite(rms_file , "parameter");
  rms_tag_fwrite_dimensions(nx , ny , nz , rms_file_get_FILE(rms_file));

  for (n = 0; n < size; n++) {
    float *src_data;
    float *target_data;

    src_data = (float *) ecl_kw_get_void_ptr(ecl_kw[n]);
    target_data = util_calloc(global_size , sizeof * target_data );

    for (k=0; k < nz; k++) {
      for (j=0; j < ny; j++) {
        for (i=0; i < nx; i++) {
          int index1D;
          int index3D;
          double fill = RMS_INACTIVE_FLOAT;
          /* TODO:
           * This currently only supports FLOAT / REAL type.
           */ 
          
          index1D = ecl_grid_get_active_index3(ecl_grid, i, j, k);
          index3D = rms_util_global_index_from_eclipse_ijk(nx, ny, nz, i, j, k);

          if (index1D >= 0)
            target_data[index3D] = src_data[index1D];
          else
            memcpy(&target_data[index3D] , &fill, sizeof(float));
        }
      }
    }

    data_key = rms_tagkey_alloc_complete("data", global_size, 
        rms_util_convert_ecl_type(ecl_kw_get_data_type(ecl_kw[n])) , target_data, true);
    rms_tag_fwrite_parameter(ecl_kw_get_header8(ecl_kw[n]), data_key, 
        rms_file_get_FILE(rms_file));
    rms_tagkey_free(data_key);
    
    util_safe_free(target_data);
  }

  rms_file_complete_fwrite(rms_file);
  rms_file_fclose(rms_file);
  rms_file_free(rms_file);
  
}
Ejemplo n.º 8
0
void block_obs_append_summary_obs( block_obs_type * block_obs , int i , int j , int k , const char * sum_key , double value , double std) {
    int active_index = ecl_grid_get_active_index3( block_obs->grid , i , j , k );
    point_obs_type * point_obs = point_obs_alloc( SOURCE_SUMMARY , i , j , k , active_index , sum_key , value , std);
    block_obs_append_point( block_obs , point_obs );
}
Ejemplo n.º 9
0
void block_obs_append_field_obs( block_obs_type * block_obs , int i , int j , int k , double value , double std) {
    int active_index = ecl_grid_get_active_index3( block_obs->grid , i , j , k );
    point_obs_type * point_obs = point_obs_alloc( SOURCE_FIELD , i , j , k , active_index , NULL , value , std);
    block_obs_append_point( block_obs , point_obs );
}