int main(int argc , char ** argv) { const char * path_case = argv[1]; char * grid_file = ecl_util_alloc_filename( NULL , path_case , ECL_EGRID_FILE , false , 0 ); char * init_file = ecl_util_alloc_filename( NULL , path_case , ECL_INIT_FILE , false , 0 ); ecl_file_type * init = ecl_file_open( init_file , 0 ); ecl_grid_type * grid = ecl_grid_alloc( grid_file ); const ecl_kw_type * poro_kw = ecl_file_iget_named_kw( init , "PORO" , 0 ); const ecl_kw_type * porv_kw = ecl_file_iget_named_kw( init , "PORV" , 0 ); ecl_kw_type * multpv = NULL; ecl_kw_type * NTG = NULL; bool error_found = false; double total_volume = 0; double total_diff = 0; int error_count = 0; int iactive; if (ecl_file_has_kw( init , "NTG")) NTG = ecl_file_iget_named_kw( init , "NTG" , 0); if (ecl_file_has_kw( init , "MULTPV")) multpv = ecl_file_iget_named_kw( init , "MULTPV" , 0); for (iactive = 0; iactive < ecl_grid_get_nactive( grid ); ++iactive) { int iglobal = ecl_grid_get_global_index1A( grid , iactive ); double grid_volume = ecl_grid_get_cell_volume1( grid , iglobal ); double eclipse_volume = ecl_kw_iget_float( porv_kw , iglobal ) / ecl_kw_iget_float( poro_kw , iactive ); if (NTG) eclipse_volume /= ecl_kw_iget_float( NTG , iactive ); if (multpv) eclipse_volume *= ecl_kw_iget_float( multpv , iactive); total_volume += grid_volume; total_diff += fabs( eclipse_volume - grid_volume ); if (!util_double_approx_equal__( grid_volume , eclipse_volume , 2.5e-3, 0.00)) { double diff = 100 * (grid_volume - eclipse_volume) / eclipse_volume; printf("Error in cell: %d V1: %g V2: %g diff:%g %% \n", iglobal , grid_volume , eclipse_volume , diff); error_count++; error_found = true; } } printf("Total volume difference: %g %% \n", 100 * total_diff / total_volume ); ecl_grid_free( grid ); ecl_file_close( init ); free( grid_file ); free( init_file ); if (error_found) { printf("Error_count: %d / %d \n",error_count , ecl_grid_get_nactive( grid )); exit(1); } else exit(0); }
bool double_vector_approx_equal( const double_vector_type * v1 , const double_vector_type * v2 , double epsilon) { bool equal = true; if (double_vector_size( v1 ) == double_vector_size( v2 )) { int i; for (i=0; i < double_vector_size( v1 ); i++) { double d1 = double_vector_iget( v1 , i ); double d2 = double_vector_iget( v2 , i ); if (!util_double_approx_equal__(d1 , d2 , epsilon)) equal = false; } } else equal = false; return equal; }
bool test_check_double_equal( double d1 , double d2) { const double tolerance = 1e-5; return util_double_approx_equal__( d1 , d2 , tolerance ); }