int main( int argc , char ** argv) { ecl_grid_type * grid = ecl_grid_alloc_rectangular( 10,11,12,1,2,3 , NULL); test_copy_grid( grid ); ecl_grid_free( grid ); exit(0); }
void test_create_simple() { test_work_area_type * work_area = test_work_area_alloc("nnc-INIT"); { int nx = 10; int ny = 10; int nz = 10; ecl_grid_type * grid0 = ecl_grid_alloc_rectangular(nx,ny,nz,1,1,1,NULL); ecl_grid_add_self_nnc(grid0, 0 ,nx*ny + 0, 0 ); ecl_grid_add_self_nnc(grid0, 1 ,nx*ny + 1, 1 ); ecl_grid_add_self_nnc(grid0, 2 ,nx*ny + 2, 2 ); { ecl_nnc_geometry_type * nnc_geo = ecl_nnc_geometry_alloc( grid0 ); test_assert_int_equal( ecl_nnc_geometry_size( nnc_geo ) , 3 ); /* Create a dummy INIT file which *ony* contains a TRANNC keyword with the correct size. */ { ecl_kw_type * trann_nnc = ecl_kw_alloc(TRANNNC_KW , ecl_nnc_geometry_size( nnc_geo ), ECL_FLOAT); fortio_type * f = fortio_open_writer( "TEST.INIT" , false, ECL_ENDIAN_FLIP ); for (int i=0; i < ecl_kw_get_size( trann_nnc); i++) ecl_kw_iset_float( trann_nnc , i , i*1.0 ); ecl_kw_fwrite( trann_nnc , f ); fortio_fclose( f ); ecl_kw_free( trann_nnc ); } } ecl_grid_free( grid0 ); } test_work_area_free( work_area ); }
void test_truncated() { test_work_area_type * work_area = test_work_area_alloc("ecl_file_truncated" ); { ecl_grid_type * grid = ecl_grid_alloc_rectangular(20,20,20,1,1,1,NULL); ecl_grid_fwrite_EGRID2( grid , "TEST.EGRID", ECL_METRIC_UNITS ); ecl_grid_free( grid ); } { ecl_file_type * ecl_file = ecl_file_open("TEST.EGRID" , 0 ); test_assert_true( ecl_file_is_instance( ecl_file ) ); ecl_file_close( ecl_file ); } { offset_type file_size = util_file_size( "TEST.EGRID"); FILE * stream = util_fopen("TEST.EGRID" , "r+"); util_ftruncate( stream , file_size / 2 ); fclose( stream ); } { ecl_file_type * ecl_file = ecl_file_open("TEST.EGRID" , 0 ); test_assert_NULL( ecl_file ); } test_work_area_free( work_area ); }
void test_create_empty() { ecl_grid_type * grid = ecl_grid_alloc_rectangular(10,10,10,1,1,1,NULL); ecl_nnc_geometry_type * nnc_geo = ecl_nnc_geometry_alloc( grid ); test_assert_true( ecl_nnc_geometry_is_instance( nnc_geo )); test_assert_int_equal( ecl_nnc_geometry_size( nnc_geo ) , 0 ); ecl_nnc_geometry_free( nnc_geo ); ecl_grid_free( grid ); }
void test_write_header() { int nx = 10; int ny = 10; int nz = 5; int_vector_type * actnum = int_vector_alloc( nx*ny*nz , 1 ); test_work_area_type * test_area = test_work_area_alloc( "ecl_init_file" ); time_t start_time = util_make_date(15 , 12 , 2010 ); ecl_grid_type * ecl_grid; int_vector_iset( actnum , 10 , 0 ); int_vector_iset( actnum , 100 , 0 ); ecl_grid = ecl_grid_alloc_rectangular(nx, ny, nz, 1, 1, 1, int_vector_get_ptr( actnum )); // Write poro with global size. { fortio_type * f = fortio_open_writer( "FOO1.INIT" , false , ECL_ENDIAN_FLIP ); ecl_kw_type * poro = ecl_kw_alloc( "PORO" , ecl_grid_get_global_size( ecl_grid ) , ECL_FLOAT_TYPE ); ecl_kw_scalar_set_float( poro , 0.10 ); ecl_init_file_fwrite_header( f , ecl_grid , poro , 7 , start_time ); ecl_kw_free( poro ); fortio_fclose( f ); } // Write poro with nactive size. { fortio_type * f = fortio_open_writer( "FOO2.INIT" , false , ECL_ENDIAN_FLIP ); ecl_kw_type * poro = ecl_kw_alloc( "PORO" , ecl_grid_get_global_size( ecl_grid ) , ECL_FLOAT_TYPE ); ecl_kw_scalar_set_float( poro , 0.10 ); ecl_init_file_fwrite_header( f , ecl_grid , poro , 7 , start_time ); ecl_kw_free( poro ); fortio_fclose( f ); } { ecl_file_type * file1 = ecl_file_open( "FOO1.INIT" , 0 ); ecl_file_type * file2 = ecl_file_open( "FOO2.INIT" , 0 ); test_assert_true( ecl_kw_equal( ecl_file_iget_named_kw( file1 , "PORV" , 0 ) , ecl_file_iget_named_kw( file2 , "PORV" , 0))); ecl_file_close( file2 ); ecl_file_close( file1 ); } // Poro == NULL { fortio_type * f = fortio_open_writer( "FOO3.INIT" , false , ECL_ENDIAN_FLIP ); ecl_init_file_fwrite_header( f , ecl_grid , NULL , 7 , start_time ); fortio_fclose( f ); } test_work_area_free( test_area ); }
int main(int argc , char ** argv) { ecl_grid_type * grid; if (argc == 1) grid = ecl_grid_alloc_rectangular(6,6,6,1,2,3,NULL); else grid = ecl_grid_alloc( argv[1] ); test_cells( grid ); ecl_grid_free( grid ); exit(0); }
int main(int argc , char ** argv) { ecl_grid_type * ecl_grid = ecl_grid_alloc_rectangular( 9 , 9 , 2 , 1 , 1 , 1 , NULL ); ecl_kw_type * fault_blk_kw = ecl_kw_alloc("FAULTBLK" , ecl_grid_get_global_size( ecl_grid ) , ECL_INT_TYPE ); test_create( ecl_grid , fault_blk_kw ); test_create_invalid( ecl_grid ); test_trace_edge( ecl_grid ); test_export(ecl_grid); test_neighbours( ecl_grid ); ecl_grid_free( ecl_grid ); ecl_kw_free( fault_blk_kw ); exit(0); }
int main(int argc, char ** argv) { if (argc != 5) { fprintf(stderr,"%s: basename nx ny nz \n",argv[0]); exit(1); } { const char * base_input = argv[1]; int nx = atoi(argv[2]); int ny = atoi(argv[3]); int nz = atoi(argv[4]); char * path , *basename; ecl_grid_type * ecl_grid; util_alloc_file_components( base_input , &path , &basename , NULL ); ecl_grid = ecl_grid_alloc_rectangular(nx,ny,nz , 1 ,1 ,1 , NULL ); { char * EGRID_file = util_alloc_filename( path , basename , "EGRID"); printf("Writing file: %s ...",EGRID_file); fflush(stdout); ecl_grid_fwrite_EGRID2( ecl_grid , EGRID_file, ERT_ECL_METRIC_UNITS); free( EGRID_file ); } { char * grdecl_file = util_alloc_filename( path , basename , "grdecl"); FILE * stream = util_fopen( grdecl_file , "w"); printf("\nWriting file: %s ...",grdecl_file); fflush(stdout); ecl_grid_fprintf_grdecl( ecl_grid , stream ); fclose( stream ); free( grdecl_file ); printf("\n"); } free( basename ); util_safe_free( path ); ecl_grid_free( ecl_grid ); } }
int main(int argc , char ** argv) { const int nx = 5; const int ny = 4; const int nz = 2; const int g = nx*ny*nz; const int nactive = g - 9; const int actnum1[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; const int actnum2[] = {0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0}; ecl_grid_type * grid = ecl_grid_alloc_rectangular(nx , ny , nz , 1 , 1 , 1 , actnum1 ); test_assert_int_equal( g , ecl_grid_get_nactive( grid )); ecl_grid_reset_actnum(grid , actnum2 ); test_assert_int_equal( nactive , ecl_grid_get_nactive( grid )); test_assert_int_equal( -1 , ecl_grid_get_active_index1( grid , 0 )); test_assert_int_equal( 0 , ecl_grid_get_active_index1( grid , 1 )); test_assert_int_equal( -1 , ecl_grid_get_active_index1( grid , 2 )); test_assert_int_equal( 1 , ecl_grid_get_global_index1A( grid , 0 )); test_assert_int_equal( 3 , ecl_grid_get_global_index1A( grid , 1 )); test_assert_int_equal( 5 , ecl_grid_get_global_index1A( grid , 2 )); ecl_grid_reset_actnum(grid , NULL ); test_assert_int_equal( g , ecl_grid_get_nactive( grid )); test_assert_int_equal( 0 , ecl_grid_get_active_index1( grid , 0 )); test_assert_int_equal( 1 , ecl_grid_get_active_index1( grid , 1 )); test_assert_int_equal( 2 , ecl_grid_get_active_index1( grid , 2 )); test_assert_int_equal( 0 , ecl_grid_get_global_index1A( grid , 0 )); test_assert_int_equal( 1 , ecl_grid_get_global_index1A( grid , 1 )); test_assert_int_equal( 2 , ecl_grid_get_global_index1A( grid , 2 )); ecl_grid_free( grid ); exit(0); }