Exemple #1
0
void test_limits_default() {
  plot_range_type * range = plot_range_alloc();
  double xmin = -1;
  double xmax =  1;
  double ymin = -2;
  double ymax =  2;

 
  plot_range_update( range , 0 , 0 );
  plot_range_update( range , 0.5 , 0.5 );
  plot_range_update( range , xmax , 0.5 );
  plot_range_update( range , 0.0 , ymin );
  plot_range_update( range , -0.5 , -1.0 );
  plot_range_update( range , xmin ,  ymax );

  plot_range_set_invert_x_axis( range , false );
  plot_range_set_invert_y_axis( range , false );
  {
    double x1 , x2 , y1 , y2;
    double w = fabs(xmax - xmin);
    double h = fabs(ymax - ymin);
    
    plot_range_get_limits( range , &x1 , &x2 , &y1 , &y2 );
    test_assert_double_equal(  xmin  -  w*0.025 , x1 );
    test_assert_double_equal(  xmax  +  w*0.025 , x2 );
    test_assert_double_equal(  ymin  -  h*0.025 , y1 );
    test_assert_double_equal(  ymax  +  h*0.025 , y2 );
  }
  plot_range_free( range );
}
Exemple #2
0
void test_create( const ecl_grid_type * grid , ecl_kw_type * fault_block_kw) {
  int k = 0;
  int i,j;
  
  for (j=0; j < ecl_grid_get_ny( grid ); j++) {
    for (i = 0; i < ecl_grid_get_nx( grid ); i++) {
      
      int g = ecl_grid_get_global_index3( grid , i,j,k);
      ecl_kw_iset_int( fault_block_kw , g , 9 );
    }
  }

  {
    fault_block_layer_type * layer = fault_block_layer_alloc( grid , k );
    test_assert_int_equal( 1 , fault_block_layer_get_next_id( layer ));
    fault_block_layer_scan_kw( layer , fault_block_kw);
    {
      fault_block_type * block = fault_block_layer_iget_block( layer , 0 );
      double x,y,z;
      ecl_grid_get_xyz3( grid , 4,4,k , &x, &y , &z );
      test_assert_double_equal( x , fault_block_get_xc( block ));
      test_assert_double_equal( y , fault_block_get_yc( block ));
    }
    
    fault_block_layer_free( layer );
  }
}
Exemple #3
0
void test_limits_inverted() {
  plot_range_type * range = plot_range_alloc();
  double xmin = 0;
  double xmax = 100;
  double ymin = 0;
  double ymax = 1000;

 
  plot_range_update( range , xmin , ymin );
  plot_range_update( range , xmax , ymin );
  plot_range_update( range , xmin , ymax );
  plot_range_update( range , xmax , ymax );
  
  plot_range_set_left_padding( range , 0.50 );
  plot_range_set_right_padding( range , 0.10 );
  plot_range_set_top_padding( range , 0.50 );
  plot_range_set_bottom_padding( range , 0.10 );
  
  plot_range_set_invert_x_axis( range , true );
  plot_range_set_invert_y_axis( range , true );
  {
    double x1 , x2 , y1 , y2;
    
    plot_range_get_limits( range , &x1 , &x2 , &y1 , &y2 );
    
    test_assert_double_equal(150 , x1 );
    test_assert_double_equal(-10 , x2 );

    test_assert_double_equal(1100 , y1 );
    test_assert_double_equal(-500 , y2 );
  }
  plot_range_free( range );
}
Exemple #4
0
void test_content() {
  rng_type * rng = rng_alloc(MZRAN , INIT_DEFAULT);
  matrix_type * PC = matrix_alloc( 3 , 10);
  matrix_type * PC_obs = matrix_alloc( 3 , 1 );
  double_vector_type * singular_values = double_vector_alloc(3 , 1);
  matrix_random_init( PC , rng );
  matrix_random_init( PC_obs , rng );
  {
    pca_plot_data_type * data = pca_plot_data_alloc("KEY" , PC , PC_obs, singular_values);
    for (int i=0; i < matrix_get_rows( PC ); i++) {
      const pca_plot_vector_type * vector = pca_plot_data_iget_vector( data , i );
      
      test_assert_double_equal( matrix_iget( PC_obs , i , 0) , 
                                pca_plot_vector_get_obs_value( vector ) );

      test_assert_double_equal( double_vector_iget( singular_values , i),
                                pca_plot_vector_get_singular_value( vector ) );

      for (int j=0; j < matrix_get_columns( PC ); j++) 
        test_assert_double_equal( matrix_iget( PC , i , j ) , pca_plot_vector_iget_sim_value( vector , j ));
      
      test_assert_int_equal( matrix_get_columns( PC ) , pca_plot_vector_get_size( vector ));

    }
    pca_plot_data_free( data );
  }

  double_vector_free( singular_values );
  matrix_free( PC );
  matrix_free( PC_obs );
}
Exemple #5
0
void test_correct_time_vector() {

  ecl_sum_type * ecl_sum = test_alloc_ecl_sum();
  time_t_vector_type * t = time_t_vector_alloc( 0 , 0 );
  time_t_vector_append(t, util_make_date_utc( 2,1,2010 ));
  time_t_vector_append(t, util_make_date_utc( 4,1,2010 ));
  time_t_vector_append(t, util_make_date_utc( 6,1,2010 ));
  time_t_vector_append(t, util_make_date_utc( 8,1,2010 ));
  ecl_sum_type * ecl_sum_resampled = ecl_sum_alloc_resample(ecl_sum, "kk", t);
  test_assert_int_equal(  ecl_sum_get_report_time(ecl_sum_resampled, 2)  , util_make_date_utc( 6,1,2010 ));

  const ecl_smspec_type * smspec_resampled = ecl_sum_get_smspec(ecl_sum_resampled);
  const smspec_node_type * node1 = ecl_smspec_iget_node(smspec_resampled, 1);
  const smspec_node_type * node2 = ecl_smspec_iget_node(smspec_resampled, 2);
  const smspec_node_type * node3 = ecl_smspec_iget_node(smspec_resampled, 3);
  test_assert_string_equal( "BPR" , smspec_node_get_keyword(node2) );
  test_assert_string_equal( "BARS" , smspec_node_get_unit(node2) );

  test_assert_double_equal(3.33333, ecl_sum_get_from_sim_time( ecl_sum_resampled, util_make_date_utc( 6,1,2010 ), node1) );
  test_assert_double_equal(3.33333, ecl_sum_get_from_sim_time( ecl_sum_resampled, util_make_date_utc( 2,1,2010 ), node2) );
  test_assert_double_equal(10.0000, ecl_sum_get_from_sim_time( ecl_sum_resampled, util_make_date_utc( 4,1,2010 ), node3) );


  ecl_sum_free(ecl_sum_resampled);
  time_t_vector_free(t);
  ecl_sum_free(ecl_sum);
}
Exemple #6
0
void test_limits_manual() {
  plot_range_type * range = plot_range_alloc();
  double xmin = -1;
  double xmax =  1;
  double ymin = -2;
  double ymax =  2;

 
  plot_range_update( range , 0 , 0 );
  plot_range_update( range , 0.5 , 0.5 );
  plot_range_update( range , xmax , 0.5 );
  plot_range_update( range , 0.0 , ymin );
  plot_range_update( range , -0.5 , -1.0 );
  plot_range_update( range , xmin ,  ymax );

  plot_range_set_manual_xmax( range , 2*xmax );
  plot_range_set_manual_ymin( range , 2*ymin );

  
  {
    double x1 , x2 , y1 , y2;
    double w = fabs(2*xmax - xmin);
    double h = fabs(ymax - 2*ymin);
    
    plot_range_get_limits( range , &x1 , &x2 , &y1 , &y2 );

    test_assert_double_equal(  xmin  -  w*0.025 , x1 );
    test_assert_double_equal(  2*xmax           , x2 );
    test_assert_double_equal(  2*ymin           , y1 );
    test_assert_double_equal(  ymax  +  h*0.025 , y2 );
  }
  plot_range_free( range );
}
Exemple #7
0
void test_diag_std() {
  const int N = 25;
  double_vector_type * data = double_vector_alloc( 0,0);
  rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); 
  matrix_type * m = matrix_alloc( N , N );
  double sum1 = 0;
  double sum2 = 0;
  int i;

  for (i=0; i < N; i++) {
    double R = rng_get_double( rng ); 
    matrix_iset(m , i , i , R);
    double_vector_iset( data , i , R );
    
    sum1 += R;
    sum2 += R*R;
  }
  {
    double mean = sum1 / N;
    double std = sqrt( sum2 / N - mean * mean );

    test_assert_double_equal( std , matrix_diag_std( m , mean ));
    test_assert_double_equal( statistics_std( data ) , matrix_diag_std( m , mean ));
    test_assert_double_equal( statistics_mean( data ) , mean );
  }
  matrix_free( m );
  rng_free( rng );
}
void test_insert_double() {
  double_vector_type * vec = double_vector_alloc(0,0);
  double_vector_append( vec , 1 );
  double_vector_insert( vec , 0 , 0 );
  
  test_assert_double_equal( 0 , double_vector_iget( vec , 0 ));
  test_assert_double_equal( 1 , double_vector_iget( vec , 1 ));
  
  double_vector_free( vec );
}
Exemple #9
0
void test_days( const ecl_sum_type * ecl_sum ) {
  time_t date1  = util_make_date( 1,1,2000);
  time_t date2  = util_make_date( 31,12,2004 );
  time_t date3  = util_make_date( 2,1,2000 );

  double days1 = ecl_sum_time2days( ecl_sum , date1 );
  double days2 = ecl_sum_time2days( ecl_sum , date2);
  double days3 = ecl_sum_time2days( ecl_sum , date3 );

  test_assert_double_equal( days1 , 0 );
  test_assert_double_equal( days2 , 1826 );
  test_assert_double_equal( days3 , 1 );
}
Exemple #10
0
void test_trace_edge( const ecl_grid_type * grid) {
  const int k = 1;
  fault_block_layer_type * layer = fault_block_layer_alloc( grid , k );
  double_vector_type * x_list = double_vector_alloc( 0,0);
  double_vector_type * y_list = double_vector_alloc( 0,0);
  fault_block_type * block = fault_block_layer_safe_get_block( layer , 99);
  int_vector_type * cell_list = int_vector_alloc(0,0);
    
  test_assert_false( fault_block_trace_edge( block , x_list , y_list , cell_list));
  fault_block_add_cell( block , 0,0);
  test_assert_true( fault_block_trace_edge( block , x_list , y_list , cell_list));
  test_assert_int_equal( 4 , double_vector_size( x_list ));
  test_assert_int_equal( 4 , double_vector_size( y_list ));
  
  test_assert_double_equal( 0 , double_vector_iget( x_list , 0 ));
  test_assert_double_equal( 1 , double_vector_iget( x_list , 1 ));
  test_assert_double_equal( 1 , double_vector_iget( x_list , 2 ));
  test_assert_double_equal( 0 , double_vector_iget( x_list , 3 ));
  
  test_assert_double_equal( 0 , double_vector_iget( y_list , 0 ));
  test_assert_double_equal( 0 , double_vector_iget( y_list , 1 ));
  test_assert_double_equal( 1 , double_vector_iget( y_list , 2 ));
  test_assert_double_equal( 1 , double_vector_iget( y_list , 3 ));

  test_assert_int_equal( 1 , int_vector_size( cell_list ));
  test_assert_int_equal( 0 , int_vector_iget( cell_list , 0));

  int_vector_free( cell_list );
  double_vector_free( x_list );
  double_vector_free( y_list );
}
Exemple #11
0
void test_set_manual1() {
  plot_range_type * range = plot_range_alloc();
  double xmin = -1;
  double xmax =  1;
  double ymin = -2;
  double ymax =  2;

  
  plot_range_set_manual_xmin( range , xmin );
  test_assert_double_equal( xmin , plot_range_get_manual_xmin( range ));
  plot_range_unset_manual_xmin( range );
  test_assert_double_equal( PLOT_RANGE_DEFAULT_MANUAL_LIMIT , plot_range_get_manual_xmin( range ));


  plot_range_set_manual_xmax( range , xmax );
  test_assert_double_equal( xmax , plot_range_get_manual_xmax( range ));
  plot_range_unset_manual_xmax( range );
  test_assert_double_equal( PLOT_RANGE_DEFAULT_MANUAL_LIMIT , plot_range_get_manual_xmax( range ));


  plot_range_set_manual_ymin( range , ymin );
  test_assert_double_equal( ymin , plot_range_get_manual_ymin( range ));
  plot_range_unset_manual_ymin( range );
  test_assert_double_equal( PLOT_RANGE_DEFAULT_MANUAL_LIMIT , plot_range_get_manual_ymin( range ));


  plot_range_set_manual_ymax( range , ymax );
  test_assert_double_equal( ymax , plot_range_get_manual_ymax( range ));
  plot_range_unset_manual_ymax( range );
  test_assert_double_equal( PLOT_RANGE_DEFAULT_MANUAL_LIMIT , plot_range_get_manual_ymax( range ));

  plot_range_free( range );
}
void test_tranLL( const ecl_grid_type * grid , const ecl_file_type * init_file , int lgr_nr1 , int lgr_nr2,
                  int size,
                  double first ,
                  double last) {

  ecl_kw_type * ecl_kw = ecl_nnc_export_get_tranll_kw(grid , init_file , lgr_nr1 , lgr_nr2 );

  printf("lgr: %d -> %d \n",lgr_nr1 , lgr_nr2);
  test_assert_not_NULL(ecl_kw);
  test_assert_true(ecl_kw_is_instance( ecl_kw ));
  test_assert_int_equal( size , ecl_kw_get_size( ecl_kw ));
  test_assert_double_equal( first , ecl_kw_iget_as_double( ecl_kw , 0 ));
  test_assert_double_equal( last , ecl_kw_iget_as_double( ecl_kw , size - 1 ));
}
Exemple #13
0
void test_empty_range() {
  plot_range_type * range = plot_range_alloc();
  
  {
    double x = 10;
    double y = 78;

    plot_range_update( range , x , y );
    test_assert_double_equal( plot_range_get_current_xmin( range ) , x );
    test_assert_double_equal( plot_range_get_current_xmax( range ) , x );
    test_assert_double_equal( plot_range_get_current_ymin( range ) , y );
    test_assert_double_equal( plot_range_get_current_ymax( range ) , y );
  }
  plot_range_free( range );
}
void test_grid() {
  const int nx = 5, ny = 6, nz = 7;
  double dxv[nx];
  double dyv[ny];
  double dzv[nz];

  double width = 1.0;
  for (int i = 0; i < nx; ++i) {
      dxv[i] = width;
      width += 1.0;
  };
  for (int i = 0; i < ny; ++i) {
      dyv[i] = width;
      width += 1.0;
  };
  for (int i = 0; i < nz; ++i) {
      dzv[i] = width;
      width += 1.0;
  };

  ecl_grid_type * ecl_grid = ecl_grid_alloc_dxv_dyv_dzv(nx,ny,nz,
                                                        dxv, dyv, dzv,
                                                        /*actnum=*/NULL);
  for (int i = 0; i < nx; ++ i) {
      for (int j = 0; j < ny; ++ j) {
          for (int k = 0; k < nz; ++ k) {
              double volume_ert = ecl_grid_get_cell_volume3(ecl_grid, i, j, k);

              test_assert_double_equal(volume_ert, dxv[i]*dyv[j]*dzv[k]);
          }
      }
  }
}
Exemple #15
0
void test_kw_io_charlength() {
  test_work_area_type * work_area = test_work_area_alloc("ecl_kw_io_charlength");
  { 
    const char * KW0 = "QWERTYUI";
    const char * KW1 = "ABCDEFGHIJTTTTTTTTTTTTTTTTTTTTTTABCDEFGHIJKLMNOP";
    ecl_kw_type * ecl_kw_out0 = ecl_kw_alloc(KW0 , 5, ECL_FLOAT);
    ecl_kw_type * ecl_kw_out1 = ecl_kw_alloc(KW1 , 5, ECL_FLOAT);
    for (int i=0; i < ecl_kw_get_size( ecl_kw_out1); i++) {
       ecl_kw_iset_float( ecl_kw_out0 , i , i*1.5 );
       ecl_kw_iset_float( ecl_kw_out1 , i , i*1.5 );
    }

    {
       fortio_type * f = fortio_open_writer( "TEST1" , false, ECL_ENDIAN_FLIP );
       test_assert_true( ecl_kw_fwrite( ecl_kw_out0, f ));
       test_assert_false(ecl_kw_fwrite( ecl_kw_out1, f ));
       fortio_fclose( f );
    }

    {
       test_assert_false( util_file_exists( "TEST1"));
    }
   
    {
       FILE * file = util_fopen("TEST2", "w");
       ecl_kw_fprintf_grdecl(ecl_kw_out1 , file);
       fclose(file);
    }
    
    {
       FILE * file = util_fopen("TEST2", "r");
       ecl_kw_type * ecl_kw_in = ecl_kw_fscanf_alloc_grdecl( file , KW1 , -1 , ECL_FLOAT);
       test_assert_string_equal(KW1, ecl_kw_get_header(ecl_kw_in) );
       test_assert_int_equal(5, ecl_kw_get_size( ecl_kw_in) );

       test_assert_double_equal(ecl_kw_iget_as_double(ecl_kw_in, 0), 0.0);
       test_assert_double_equal(ecl_kw_iget_as_double(ecl_kw_in, 4), 6.0);

       fclose(file);
    }
    
    ecl_kw_free( ecl_kw_out0 );
    ecl_kw_free( ecl_kw_out1 );
  }
  test_work_area_free( work_area );
}
Exemple #16
0
void test_double() {
  size_t N = 1000;
  double i;
  ecl_kw_type * kw = ecl_kw_alloc("KW" , N , ECL_DOUBLE_TYPE);
  for (i=0; i < N; i++)
    test_assert_double_equal( 0 , ecl_kw_iget_double( kw , i ));

  ecl_kw_free( kw );
}
void test_load() {
  test_work_area_type * work_area = test_work_area_alloc("unsmry_loader");
  ecl_sum_type * ecl_sum = write_ecl_sum();
  test_assert_true( util_file_exists("CASE.SMSPEC") );
  test_assert_true( util_file_exists("CASE.UNSMRY") );
  ecl::unsmry_loader * loader = new ecl::unsmry_loader(ecl_sum_get_smspec(ecl_sum), "CASE.UNSMRY", 0);

  const std::vector<double> FOPT_value = loader->get_vector(1);
  const std::vector<double> BPR_value  = loader->get_vector(2);
  const std::vector<double> WWCT_value = loader->get_vector(3);
  test_assert_int_equal( FOPT_value.size(), 4 );
  test_assert_double_equal( FOPT_value[3] , 6.0 );
  test_assert_double_equal( BPR_value[2]  , 10.0 );
  test_assert_double_equal( WWCT_value[1] , 10.0 );

  delete loader;
  ecl_sum_free(ecl_sum);
  test_work_area_free(work_area);
}
void test_range_fill_double() {
  double_vector_type * double_vector = double_vector_alloc(0,0);
  double_vector_range_fill( double_vector , 1,2,10 ); /* 1 , 3 , 5 , 7 , 9 */
  
  test_assert_double_equal( double_vector_size( double_vector ), 5);
  test_assert_double_equal( double_vector_iget( double_vector , 0 ) , 1 );
  test_assert_double_equal( double_vector_iget( double_vector , 1 ) , 3 );
  test_assert_double_equal( double_vector_iget( double_vector , 2 ) , 5 );
  test_assert_double_equal( double_vector_iget( double_vector , 3 ) , 7 );
  test_assert_double_equal( double_vector_iget( double_vector , 4 ) , 9 );
  
  double_vector_range_fill( double_vector , 3,3,9 ); /* 3,6,9 */
  test_assert_double_equal( double_vector_size( double_vector ), 3);
  test_assert_double_equal( double_vector_iget( double_vector , 0 ) , 3 );
  test_assert_double_equal( double_vector_iget( double_vector , 1 ) , 6 );
  test_assert_double_equal( double_vector_iget( double_vector , 2 ) , 9 );

  double_vector_free( double_vector );
}
Exemple #19
0
void test_gendata( enkf_main_type * enkf_main , const char * obs_key , int report_step ) {
    enkf_obs_type * enkf_obs = enkf_main_get_obs( enkf_main );

    obs_vector_type * obs_vector = enkf_obs_get_vector( enkf_obs , obs_key);

    {
        enkf_plot_gendata_type * gen_data = enkf_plot_gendata_alloc_from_obs_vector( obs_vector );

        enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
        gen_obs_type * gen_obs = obs_vector_iget_node( obs_vector , report_step );

        {

            double  value;
            double  std;
            bool valid;
            gen_obs_user_get_with_data_index(gen_obs , "0" , &value , &std , &valid );
            test_assert_double_equal( 0.143841 , value );
            test_assert_double_equal( 0.0300 ,  std );
            test_assert_true( valid );

        }

        enkf_plot_gendata_load(gen_data, fs, report_step, FORECAST, NULL);

        test_assert_int_equal( enkf_main_get_ensemble_size( enkf_main ) , enkf_plot_gendata_get_size( gen_data ));

        {
            enkf_plot_genvector_type * vector = enkf_plot_gendata_iget( gen_data , 24);
            test_assert_true( enkf_plot_genvector_is_instance( vector ));
            test_assert_double_equal(  0.675537 , enkf_plot_genvector_iget( vector , 0 ));
            test_assert_double_equal( 0.682635 , enkf_plot_genvector_iget( vector , 1 ));
            test_assert_double_equal( 0.616371 , enkf_plot_genvector_iget( vector , 2 ));


        }

        {
            enkf_plot_genvector_type * vector = enkf_plot_gendata_iget( gen_data , 9 );
            test_assert_true( enkf_plot_genvector_is_instance( vector ));
            test_assert_double_equal( -0.515033 , enkf_plot_genvector_iget( vector , 0 ));
            test_assert_double_equal( -0.507350 , enkf_plot_genvector_iget( vector , 1 ));
            test_assert_double_equal( -0.541030 , enkf_plot_genvector_iget( vector , 2 ));
        }


        enkf_plot_gendata_free( gen_data );
    }


}
Exemple #20
0
void test_overlapping_lines_not_in_contact_vertical(double ** points) {
  double x0 = -100;
  double y0 = -100;

  points[0][0] = 0;
  points[1][0] = 0;

  points[0][1] = 0;
  points[1][1] = 1;


  points[2][0] = 0;
  points[3][0] = 0;

  points[2][1] = 2;
  points[3][1] = 3;

  test_assert_int_equal(GEO_UTIL_NOT_CROSSING , geo_util_xsegments( (const double **) points , &x0 , &y0 ));
  test_assert_double_equal( x0 , -100 );
  test_assert_double_equal( y0 , -100 );
}
Exemple #21
0
void test_det2() {
  matrix_type * m = matrix_alloc(2,2);
  rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); 
  matrix_random_init( m , rng );
  {
    double det2 = matrix_det2( m );
    double det = matrix_det( m );

    test_assert_double_equal( det , det2 );
  }
  matrix_free( m );
  rng_free( rng );
}
Exemple #22
0
void test_update_range() {
  plot_range_type * range = plot_range_alloc();

  double xmin = -1;
  double xmax =  1;
  double ymin = -1;
  double ymax =  1;

  plot_range_update( range , 0 , 0 );
  plot_range_update( range , 0.5 , 0.5 );
  plot_range_update( range , 1.0 , 0.5 );
  plot_range_update( range , 0.0 , -1.0 );
  plot_range_update( range , -0.5 , -1.0 );
  plot_range_update( range , -1.0 ,  1.0 );

  test_assert_double_equal( xmin , plot_range_get_current_xmin( range ) );
  test_assert_double_equal( xmax , plot_range_get_current_xmax( range ) );
  test_assert_double_equal( ymin , plot_range_get_current_ymin( range ) );
  test_assert_double_equal( ymax , plot_range_get_current_ymax( range ) );

  plot_range_free( range );
}
Exemple #23
0
void test_vertical_line(double ** points) {
  double x0 = -100;
  double y0 = -100;

  points[0][0] = -1;
  points[1][0] =  1;

  points[0][1] = -1;
  points[1][1] =  1;


  points[2][0] =  0;
  points[3][0] =  0;

  points[2][1] =  1;
  points[3][1] = -1;


  test_assert_int_equal(GEO_UTIL_LINES_CROSSING , geo_util_xlines( (const double **) points , &x0 , &y0 ));
  test_assert_double_equal( x0 , 0 );
  test_assert_double_equal( y0 , 0 );
}
Exemple #24
0
void test_overlapping_lines_in_contact(double ** points) {
  double x0 = -100;
  double y0 = -100;

  points[0][0] = 0;
  points[1][0] = 1;

  points[0][1] = 0;
  points[1][1] = 1;


  points[2][0] = -1;
  points[3][0] =  2;

  points[2][1] = -1;
  points[3][1] =  2;


  test_assert_int_equal(GEO_UTIL_LINES_OVERLAPPING , geo_util_xlines( (const double **) points , &x0 , &y0 ));
  test_assert_double_equal( x0 , -100 );
  test_assert_double_equal( y0 , -100 );
}
Exemple #25
0
void test_parallell_lines(double ** points) {
  double x0 = -100;
  double y0 = -100;

  points[0][0] = 0;
  points[1][0] = 10;

  points[0][1] = 1;
  points[1][1] = 1;


  points[2][0] = 0;
  points[3][0] = 10;

  points[2][1] = 4;
  points[3][1] = 4;


  test_assert_int_equal(GEO_UTIL_LINES_PARALLELL , geo_util_xlines( (const double **) points , &x0 , &y0 ));
  test_assert_double_equal( x0 , -100 );
  test_assert_double_equal( y0 , -100 );
}
Exemple #26
0
void test_degenerate_line(double ** points) {
  double x0 = -100;
  double y0 = -100;

  points[0][0] = -1;
  points[1][0] = -1;

  points[0][1] = -1;
  points[1][1] = -1;


  points[2][0] =  0;
  points[3][0] =  0;

  points[2][1] =  1;
  points[3][1] = -1;


  test_assert_int_equal(GEO_UTIL_LINES_DEGENERATE , geo_util_xlines( (const double **) points , &x0 , &y0 ));
  test_assert_double_equal( x0 , -100 );
  test_assert_double_equal( y0 , -100 );
}
void test_iget_as_double() {
  stringlist_type * s = stringlist_alloc_new();
  stringlist_append_copy(s , "1000.90" );
  stringlist_append_copy(s , "1000" );
  stringlist_append_copy(s , "XXXX" );

  {
    double value;
    bool valid;

    value = stringlist_iget_as_double( s , 0 , &valid);
    test_assert_double_equal( value , 1000.90);
    test_assert_true( valid );

    value = stringlist_iget_as_double( s , 1 , &valid);
    test_assert_double_equal( value , 1000.0);
    test_assert_true( valid );

    value = stringlist_iget_as_double( s , 2 , &valid);
    test_assert_double_equal( value , -1);
    test_assert_false( valid );
  }
}
Exemple #28
0
// Hardcoded values from a test case with a PLT.
void test_plt( const char * plt_file ) {
  ecl_rft_file_type * plt = ecl_rft_file_alloc( plt_file );
  ecl_rft_node_type * plt_node = ecl_rft_file_iget_node( plt , 11 );

  test_assert_true( ecl_rft_node_is_PLT( plt_node ));
  test_assert_false( ecl_rft_node_is_MSW( plt_node ));
  test_assert_int_equal( 22 , ecl_rft_node_get_size( plt_node ));

  test_assert_double_equal( 244.284  , ecl_rft_node_iget_pressure( plt_node , 0 ));
  test_assert_double_equal( 167.473  , ecl_rft_node_iget_orat( plt_node , 0 ));
  test_assert_double_equal( 41682.2  , ecl_rft_node_iget_grat( plt_node , 0 ));
  test_assert_double_equal( 0.958927 , ecl_rft_node_iget_wrat( plt_node , 0 ));
  
  {
    int i,j,k;

    ecl_rft_node_iget_ijk( plt_node , 0 , &i , &j , &k );
    test_assert_int_equal( 39 , i );
    test_assert_int_equal( 33 , j );
    test_assert_int_equal( 16 , k );    
    
    ecl_rft_node_iget_ijk( plt_node , 21 , &i , &j , &k );
    test_assert_int_equal( 44 , i );
    test_assert_int_equal( 34 , j );
    test_assert_int_equal(  7 , k );    

    for (i=0; i < ecl_rft_node_get_size( plt_node );  i++) {
      const ecl_rft_cell_type * cell1 = ecl_rft_node_iget_cell( plt_node , i );
      const ecl_rft_cell_type * cell2 = ecl_rft_node_iget_cell_sorted( plt_node , i );

      test_assert_ptr_equal( cell1 , cell2 );
    }
    ecl_rft_node_inplace_sort_cells( plt_node );
  }
  
  ecl_rft_file_free( plt );
}
Exemple #29
0
// Hardcoded GURBAT values
void test_rft( const char * rft_file ) {
  ecl_rft_file_type * rft = ecl_rft_file_alloc( rft_file );
  ecl_rft_node_type * rft_node = ecl_rft_file_iget_node( rft , 0 );
  
  test_assert_true( ecl_rft_node_is_RFT( rft_node ));
  test_assert_int_equal( 14 , ecl_rft_node_get_size( rft_node ));
  test_assert_false( ecl_rft_node_is_MSW( rft_node ));
  
  test_assert_double_equal( 260.6111   , ecl_rft_node_iget_pressure( rft_node , 0 ));
  test_assert_double_equal( 0.0581993  , ecl_rft_node_iget_soil( rft_node , 0 ));
  test_assert_double_equal( 0.9405648  , ecl_rft_node_iget_swat( rft_node , 0 ));
  test_assert_double_equal( 0.00123579  , ecl_rft_node_iget_sgas( rft_node , 0 ));

  {
    int i,j,k;

    ecl_rft_node_iget_ijk( rft_node , 0 , &i , &j , &k );
    test_assert_int_equal( 32 , i );
    test_assert_int_equal( 53 , j );
    test_assert_int_equal( 0  , k );    

    ecl_rft_node_iget_ijk( rft_node , 13 , &i , &j , &k );
    test_assert_int_equal( 32 , i );
    test_assert_int_equal( 54 , j );
    test_assert_int_equal( 12 , k );    

    for (i=0; i < ecl_rft_node_get_size( rft_node );  i++) {
      const ecl_rft_cell_type * cell1 = ecl_rft_node_iget_cell( rft_node , i );
      const ecl_rft_cell_type * cell2 = ecl_rft_node_iget_cell_sorted( rft_node , i );

      test_assert_ptr_equal( cell1 , cell2 );
    }
  }
  ecl_rft_node_inplace_sort_cells( rft_node );

  ecl_rft_file_free( rft );
}
Exemple #30
0
void test_det4() {
  matrix_type * m = matrix_alloc(4  , 4 );
  rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); 
  for (int i=0; i < 10; i++) {
    matrix_random_init( m , rng );
    {
      double det4 = matrix_det4( m );
      double det = matrix_det( m );
   
      test_assert_double_equal( det , det4 );
    }
  }

  matrix_free( m );
  rng_free( rng );
}