Пример #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
void well_segment_collection_link(const  well_segment_collection_type * segment_collection) {
  int index;
  for (index = 0; index < vector_get_size( segment_collection->__segment_storage); index++) {
    well_segment_type * segment = well_segment_collection_iget( segment_collection , index );
    int outlet_segment_id = well_segment_get_outlet_id( segment );
    if (!well_segment_nearest_wellhead(segment)) {
      well_segment_type * target_segment = well_segment_collection_get( segment_collection , outlet_segment_id );
      well_segment_link( segment , target_segment );
    }
  }
}
Пример #3
0
void well_segment_collection_add_connections(well_segment_collection_type * segment_collection , 
                                             const char * grid_name , 
                                             const well_conn_collection_type * connections) {
  int iconn;
  for (iconn = 0; iconn < well_conn_collection_get_size( connections ); iconn++) {
    well_conn_type * conn = well_conn_collection_iget( connections , iconn );
    if (well_conn_MSW( conn )) {
      int segment_id =  well_conn_get_segment_id( conn );
      well_segment_type * segment = well_segment_collection_get( segment_collection , segment_id );
      well_segment_add_connection( segment , grid_name , conn );
    }
  }
}