Exemplo n.º 1
0
/*ARGSUSED1*/
static void
key(unsigned char key, int x, int y) {
    switch(key) {
    case 'h': help(); break;
    case 'g': gfunc(); break;
    case 't': tfunc(); break;
    case 'z': zfunc(); break;
    case 'x': xfunc(); break;
    case 'p': pfunc(); break;
    case '\033': exit(EXIT_SUCCESS); break;
    default: break;
    }
    glutPostRedisplay();
}
Exemplo n.º 2
0
void test_create() {
  ecl_grid_type * ecl_grid;
  int nx = 100;
  int ny = 100;
  int nz = 10;

  double * DXV = util_malloc( nx * sizeof * DXV );
  double * DYV = util_malloc( ny * sizeof * DYV );
  double * DZV = util_malloc( nz * sizeof * DZV );
  double * DEPTHZ = util_malloc( (nx + 1) * (ny + 1) * sizeof * DEPTHZ);

  for (int i=0; i < nx; i++)
    DXV[i] = 1.0 / nx;

  for (int j=0; j < ny; j++)
    DYV[j] = 1.0 / ny;

  for (int k=0; k < nz; k++)
    DZV[k] = 3.0 / nz;
  

  for (int j=0; j <= ny; j++) {
    double y = center_sum(DYV , j);
    for (int i=0; i <= nx; i++) {
      double x = center_sum(DXV , i);
      
      DEPTHZ[i + j*(nx + 1)] = zfunc( x,y );
    }
  }

  ecl_grid = ecl_grid_alloc_dxv_dyv_dzv_depthz( nx,ny,nz,DXV , DYV , DZV , DEPTHZ , NULL);
  
  for (int k=0; k < nz; k++) {
    double z0 = center_sum(DZV , k ) - 0.5*DZV[0];
    for (int j=0; j < ny; j++) {
      double y0 = center_sum(DYV , j );
      for (int i=0; i < nx; i++) {
        double x0 = center_sum(DXV , i );
        double xc,yc,zc;
        int g = ecl_grid_get_global_index3( ecl_grid , i , j , k );
        
        ecl_grid_get_xyz1( ecl_grid , g , &xc , &yc , &zc); 
        test_assert_double_equal( x0 , xc );
        test_assert_double_equal( y0 , yc );

        ecl_grid_get_cell_corner_xyz1( ecl_grid , g , 0 , &xc , &yc , &zc);
        test_assert_double_equal( z0 + zfunc(x0 , y0) , zc );

        ecl_grid_get_cell_corner_xyz1( ecl_grid , g , 4, &xc , &yc , &zc);
        test_assert_double_equal( z0 + zfunc(x0 , y0) + DZV[k] , zc );
      }
    }
  }


  free( DXV );
  free( DYV );
  free( DZV );
  free( DEPTHZ );
  ecl_grid_free( ecl_grid );
}