Пример #1
0
int main(int argc , char ** argv) {
  test_install_SIGNALS();

  double * rseg_data = util_calloc( 100 , sizeof * rseg_data );
  well_segment_collection_type * sc = well_segment_collection_alloc();
  test_assert_not_NULL( sc );
  test_assert_int_equal( well_segment_collection_get_size( sc ) , 0 );

  {
    int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
    int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
    well_segment_type * ws = well_segment_alloc(89 , outlet_segment_id , branch_nr, rseg_data);
    
    well_segment_collection_add( sc , ws );
    test_assert_int_equal( well_segment_collection_get_size( sc ) , 1);
    test_assert_ptr_equal( well_segment_collection_iget( sc , 0 ) , ws );
    
    test_assert_false( well_segment_collection_has_segment( sc , 451 ));
    test_assert_true( well_segment_collection_has_segment( sc , 89 ));
    test_assert_ptr_equal( well_segment_collection_get( sc , 89 ) , ws );
  }

  {
    int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
    int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
    well_segment_type * ws = well_segment_alloc(90 , outlet_segment_id , branch_nr , rseg_data);
    
    well_segment_collection_add( sc , ws );
    test_assert_int_equal( well_segment_collection_get_size( sc ) , 2);
    test_assert_ptr_equal( well_segment_collection_iget( sc , 1 ) , ws );
    
    test_assert_false( well_segment_collection_has_segment( sc , 451 ));
    test_assert_true( well_segment_collection_has_segment( sc , 89 ));
    test_assert_true( well_segment_collection_has_segment( sc , 90 ));
    test_assert_ptr_equal( well_segment_collection_get( sc , 90 ) , ws );
    test_assert_NULL( well_segment_collection_get( sc , 76 ));
  }

  {
    int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
    int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
    well_segment_type * ws = well_segment_alloc(89 , outlet_segment_id , branch_nr, rseg_data);
    
    well_segment_collection_add( sc , ws );
    test_assert_int_equal( well_segment_collection_get_size( sc ) , 2);
    test_assert_ptr_equal( well_segment_collection_iget( sc , 0 ) , ws );
    
    test_assert_false( well_segment_collection_has_segment( sc , 451 ));
    test_assert_true( well_segment_collection_has_segment( sc , 89 ));
    test_assert_ptr_equal( well_segment_collection_get( sc , 89 ) , ws );
  }
  
  free( rseg_data );
  well_segment_collection_free( sc );
  
  exit(0);
}
Пример #2
0
int well_segment_collection_load_from_kw( well_segment_collection_type * segment_collection , int well_nr , 
                                          const ecl_kw_type * iwel_kw , 
                                          const ecl_kw_type * iseg_kw , 
                                          const ecl_kw_type * rseg_kw , 
                                          const ecl_rsthead_type * rst_head) {

  int iwel_offset = rst_head->niwelz * well_nr;
  int segment_well_nr = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_SEGMENTED_WELL_NR_ITEM) - 1; 
  int segments_added = 0;
      
  if (segment_well_nr != IWEL_SEGMENTED_WELL_NR_NORMAL_VALUE) {
    int segment_index;
    for (segment_index = 0; segment_index < rst_head->nsegmx; segment_index++) {
      int segment_id = segment_index + WELL_SEGMENT_OFFSET;
      well_segment_type * segment = well_segment_alloc_from_kw( iseg_kw , rseg_kw , rst_head , segment_well_nr , segment_index , segment_id );

      if (well_segment_active( segment )) {
        well_segment_collection_add( segment_collection , segment );
        segments_added++;
      } else
        well_segment_free( segment );
    }
  }
  return segments_added;
}