static void ecl_nnc_geometry_add_pairs( const ecl_nnc_geometry_type * nnc_geo , const ecl_grid_type * grid ) { int lgr_nr1 = ecl_grid_get_lgr_nr( grid ); const ecl_grid_type * global_grid = ecl_grid_get_global_grid( grid ); if (!global_grid) global_grid = grid; for (int global_index1 = 0; global_index1 < ecl_grid_get_global_size( grid ); global_index1++) { const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1( grid , global_index1 ); if (!nnc_info) continue; for (int lgr_index2 = 0; lgr_index2 < nnc_info_get_size( nnc_info ); lgr_index2++) { const nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index2 ); const int_vector_type * grid2_index_list = nnc_vector_get_grid_index_list( nnc_vector ); const int_vector_type * nnc_index_list = nnc_vector_get_nnc_index_list( nnc_vector ); int lgr_nr2 = nnc_vector_get_lgr_nr( nnc_vector ); for (int index2 = 0; index2 < nnc_vector_get_size( nnc_vector ); index2++) { ecl_nnc_pair_type pair; pair.grid_nr1 = lgr_nr1; pair.global_index1 = global_index1; pair.grid_nr2 = lgr_nr2; pair.global_index2 = int_vector_iget( grid2_index_list , index2 ); pair.input_index = int_vector_iget( nnc_index_list, index2 ); struct_vector_append( nnc_geo->data , &pair); } } } }
void test_append_iget() { struct test_struct d1,d2; struct_vector_type * struct_vector = struct_vector_alloc( sizeof d1 ); d1.x = 100; d1.y = 99; d1.z = 234; struct_vector_append( struct_vector , &d1 ); test_assert_int_equal( struct_vector_get_size( struct_vector ) , 1 ); test_assert_false( d1.x == d2.x ); test_assert_false( d1.y == d2.y ); test_assert_false( d1.z == d2.z ); struct_vector_iget( struct_vector , 0 , &d2); test_assert_true( d1.x == d2.x ); test_assert_true( d1.y == d2.y ); test_assert_true( d1.z == d2.z ); struct_vector_reset( struct_vector ); test_assert_int_equal( struct_vector_get_size( struct_vector ) , 0 ); struct_vector_free( struct_vector ); }
static void layer_trace_block_edge__( const layer_type * layer , int_point2d_type start_point , int i , int j , int value , edge_dir_enum dir , struct_vector_type * corner_list, int_vector_type * cell_list) { int_point2d_type current_point; int_point2d_type next_point; current_point.i = i; current_point.j = j; next_point = current_point; if (dir == BOTTOM_EDGE) point_shift( &next_point , 1 , 0 ); else if (dir == RIGHT_EDGE) { point_shift( ¤t_point , 1 , 0 ); point_shift( &next_point , 1 , 1 ); } else if (dir == TOP_EDGE) { point_shift( ¤t_point , 1 , 1 ); point_shift( &next_point , 0 , 1 ); } else if (dir == LEFT_EDGE) point_shift( ¤t_point , 0 , 1 ); struct_vector_append( corner_list , ¤t_point ); { int cell_index = i + j*layer->nx; int_vector_append( cell_list , cell_index ); } if ( !point_equal(&start_point , &next_point) ) { if (dir == BOTTOM_EDGE) { if (layer_iget_edge_value( layer , i,j,RIGHT_EDGE) == value) layer_trace_block_edge__( layer , start_point , i , j , value , RIGHT_EDGE , corner_list , cell_list); else if (layer_iget_edge_value( layer , i + 1 , j ,BOTTOM_EDGE) == value) layer_trace_block_edge__( layer , start_point , i + 1 , j , value , BOTTOM_EDGE , corner_list , cell_list); else if (layer_iget_edge_value( layer , i + 1 , j - 1 , LEFT_EDGE) == -value) layer_trace_block_edge__( layer , start_point , i + 1 , j -1 , value , LEFT_EDGE , corner_list , cell_list); else util_abort("%s: dir == BOTTOM_EDGE \n",__func__); } if (dir == RIGHT_EDGE) { if (layer_iget_edge_value( layer , i,j,TOP_EDGE) == -value) layer_trace_block_edge__( layer , start_point , i , j , value , TOP_EDGE , corner_list , cell_list); else if (layer_iget_edge_value( layer , i , j + 1 ,RIGHT_EDGE) == value) layer_trace_block_edge__( layer , start_point , i , j + 1, value , RIGHT_EDGE , corner_list , cell_list); else if (layer_iget_edge_value( layer , i + 1 , j + 1 ,BOTTOM_EDGE) == value) layer_trace_block_edge__( layer , start_point , i + 1 , j + 1, value , BOTTOM_EDGE , corner_list , cell_list); else util_abort("%s: dir == RIGHT_EDGE \n",__func__); } if (dir == TOP_EDGE) { if (layer_iget_edge_value( layer , i , j , LEFT_EDGE) == -value) layer_trace_block_edge__( layer , start_point , i , j , value , LEFT_EDGE , corner_list , cell_list); else if (layer_iget_edge_value( layer , i - 1 , j ,TOP_EDGE) == -value) layer_trace_block_edge__( layer , start_point , i - 1 , j , value , TOP_EDGE , corner_list , cell_list); else if (layer_iget_edge_value( layer , i - 1 , j + 1 ,RIGHT_EDGE) == value) layer_trace_block_edge__( layer , start_point , i - 1 , j + 1, value , RIGHT_EDGE , corner_list , cell_list); else util_abort("%s: dir == TOP_EDGE \n",__func__); } if (dir == LEFT_EDGE) { if (layer_iget_edge_value( layer , i , j , BOTTOM_EDGE) == value) layer_trace_block_edge__( layer , start_point , i , j , value , BOTTOM_EDGE , corner_list , cell_list); else if (layer_iget_edge_value( layer , i , j - 1 , LEFT_EDGE) == -value) layer_trace_block_edge__( layer , start_point , i , j - 1, value , LEFT_EDGE , corner_list , cell_list); else if (layer_iget_edge_value( layer , i -1 , j - 1 , TOP_EDGE) == -value) layer_trace_block_edge__( layer , start_point , i-1 , j - 1, value , TOP_EDGE , corner_list , cell_list); else util_abort("%s: dir == LEFT_EDGE \n",__func__); } } }