コード例 #1
0
ファイル: ecl_fault_block_layer.c プロジェクト: agchitu/ert
void test_export( const ecl_grid_type * grid) {
  fault_block_layer_type * layer = fault_block_layer_alloc( grid , 0 );
  ecl_kw_type * ecl_kw1 = ecl_kw_alloc("FAULTBLK" , ecl_grid_get_global_size( grid )     , ECL_INT_TYPE );
  ecl_kw_type * ecl_kw2 = ecl_kw_alloc("FAULTBLK" , ecl_grid_get_global_size( grid ) + 1 , ECL_INT_TYPE );
  ecl_kw_type * ecl_kw3 = ecl_kw_alloc("FAULTBLK" , ecl_grid_get_global_size( grid )     , ECL_FLOAT_TYPE );
  fault_block_type * block = fault_block_layer_add_block( layer , 10 );
  
  fault_block_add_cell( block , 0 , 0 );
  fault_block_add_cell( block , 1 , 0 );
  fault_block_add_cell( block , 1 , 1 );
  fault_block_add_cell( block , 0 , 1 );


  test_assert_true( fault_block_layer_export( layer , ecl_kw1 ));
  test_assert_false( fault_block_layer_export( layer , ecl_kw2 ));
  test_assert_false( fault_block_layer_export( layer , ecl_kw3 ));

  {
    int nx = ecl_grid_get_nx( grid );
   
    test_assert_int_equal( ecl_kw_iget_int( ecl_kw1 , 0 ) , 10 );
    test_assert_int_equal( ecl_kw_iget_int( ecl_kw1 , 1 ) , 10 );
    test_assert_int_equal( ecl_kw_iget_int( ecl_kw1 , nx ) , 10 );
    test_assert_int_equal( ecl_kw_iget_int( ecl_kw1 , nx + 1 ) , 10 );
  }
  test_assert_int_equal( 40 , ecl_kw_element_sum_int( ecl_kw1 ));

  fault_block_layer_free( layer );
  ecl_kw_free( ecl_kw1 );
  ecl_kw_free( ecl_kw2 );
  ecl_kw_free( ecl_kw3 );
}
コード例 #2
0
ファイル: enkf_analysis_config.c プロジェクト: danielfmva/ert
void test_min_realisations( ) {
  analysis_config_type * ac = create_analysis_config( );
  test_assert_int_equal( 0 , analysis_config_get_min_realisations( ac ) );
  analysis_config_set_min_realisations( ac , 26 );
  test_assert_int_equal( 26 , analysis_config_get_min_realisations( ac ) );
  analysis_config_free( ac );
}
コード例 #3
0
void test_split() {
  stringlist_type *  s1 = stringlist_alloc_from_split("My Name    is Joakim Hove" , " ");
  test_assert_int_equal( 5 , stringlist_get_size( s1 ));
  test_assert_string_equal( "My" , stringlist_iget( s1 , 0 ));
  test_assert_string_equal( "Name" , stringlist_iget( s1  , 1 ));
  test_assert_string_equal( "is" , stringlist_iget( s1  , 2 ));
  test_assert_string_equal( "Joakim" , stringlist_iget( s1  , 3 ));
  test_assert_string_equal( "Hove" , stringlist_iget( s1  , 4 ));
  stringlist_free( s1 );


  s1 = stringlist_alloc_from_split("StringWithNoSPlit" , " ");
  test_assert_int_equal( 1 , stringlist_get_size( s1 ));
  test_assert_string_equal( "StringWithNoSPlit" , stringlist_iget( s1 , 0 ));
  stringlist_free( s1 );

  s1 = stringlist_alloc_from_split("A:B::C:D:" , ":");
  test_assert_int_equal( 4 , stringlist_get_size( s1 ));
  test_assert_string_equal( "A" , stringlist_iget( s1 , 0 ));
  test_assert_string_equal( "B" , stringlist_iget( s1 , 1 ));
  test_assert_string_equal( "C" , stringlist_iget( s1 , 2 ));
  test_assert_string_equal( "D" , stringlist_iget( s1 , 3 ));
  stringlist_free( s1 );

  s1 = stringlist_alloc_from_split("A:B::C:D:" , "::");
  test_assert_int_equal( 4 , stringlist_get_size( s1 ));
  test_assert_string_equal( "A" , stringlist_iget( s1 , 0 ));
  test_assert_string_equal( "B" , stringlist_iget( s1 , 1 ));
  test_assert_string_equal( "C" , stringlist_iget( s1 , 2 ));
  test_assert_string_equal( "D" , stringlist_iget( s1 , 3 ));
  stringlist_free( s1 );
}
コード例 #4
0
ファイル: ecl_fault_block_layer.c プロジェクト: agchitu/ert
void test_trace_edge( const ecl_grid_type * grid) {
  const int k = 1;
  fault_block_layer_type * layer = fault_block_layer_alloc( grid , k );
  double_vector_type * x_list = double_vector_alloc( 0,0);
  double_vector_type * y_list = double_vector_alloc( 0,0);
  fault_block_type * block = fault_block_layer_safe_get_block( layer , 99);
  int_vector_type * cell_list = int_vector_alloc(0,0);
    
  test_assert_false( fault_block_trace_edge( block , x_list , y_list , cell_list));
  fault_block_add_cell( block , 0,0);
  test_assert_true( fault_block_trace_edge( block , x_list , y_list , cell_list));
  test_assert_int_equal( 4 , double_vector_size( x_list ));
  test_assert_int_equal( 4 , double_vector_size( y_list ));
  
  test_assert_double_equal( 0 , double_vector_iget( x_list , 0 ));
  test_assert_double_equal( 1 , double_vector_iget( x_list , 1 ));
  test_assert_double_equal( 1 , double_vector_iget( x_list , 2 ));
  test_assert_double_equal( 0 , double_vector_iget( x_list , 3 ));
  
  test_assert_double_equal( 0 , double_vector_iget( y_list , 0 ));
  test_assert_double_equal( 0 , double_vector_iget( y_list , 1 ));
  test_assert_double_equal( 1 , double_vector_iget( y_list , 2 ));
  test_assert_double_equal( 1 , double_vector_iget( y_list , 3 ));

  test_assert_int_equal( 1 , int_vector_size( cell_list ));
  test_assert_int_equal( 0 , int_vector_iget( cell_list , 0));

  int_vector_free( cell_list );
  double_vector_free( x_list );
  double_vector_free( y_list );
}
コード例 #5
0
ファイル: ecl_nnc_vector.c プロジェクト: myrseth/ert
int main(int argc , char ** argv) {
    int lgr_nr = 100;
    nnc_vector_type * vector = nnc_vector_alloc( lgr_nr );

    test_assert_true( nnc_vector_is_instance( vector ));
    test_assert_int_equal( lgr_nr , nnc_vector_get_lgr_nr( vector ));

    nnc_vector_add_nnc( vector , 100 );
    nnc_vector_add_nnc( vector , 200 );
    nnc_vector_add_nnc( vector , 300 );

    nnc_vector_add_nnc( vector , 100 );
    nnc_vector_add_nnc( vector , 200 );
    nnc_vector_add_nnc( vector , 300 );


    {
        const int_vector_type * index_list = nnc_vector_get_index_list( vector );

        test_assert_int_equal( 3 , int_vector_size( index_list ));
        test_assert_int_equal( 100 , int_vector_iget( index_list , 0 ));
        test_assert_int_equal( 200 , int_vector_iget( index_list , 1 ));
        test_assert_int_equal( 300 , int_vector_iget( index_list , 2 ));
    }

    nnc_vector_free( vector );
    exit(0);
}
コード例 #6
0
int main( int argc , char ** argv) {
  const char * egrid_file = argv[1];

  ecl_grid_type * grid = ecl_grid_alloc( egrid_file );
  ecl_file_type * gfile = ecl_file_open( egrid_file , 0 );
  const ecl_kw_type * nnc1_kw = ecl_file_iget_named_kw( gfile , "NNC1" ,0 );
  const ecl_kw_type * nnc2_kw = ecl_file_iget_named_kw( gfile , "NNC2" ,0 );
  const int_vector_type * index_list = ecl_grid_get_nnc_index_list( grid );
  
  {
    int_vector_type * nnc = int_vector_alloc(0,0);
    
    int_vector_set_many( nnc , 0 , ecl_kw_get_ptr( nnc1_kw ) , ecl_kw_get_size( nnc1_kw ));
    int_vector_append_many( nnc , ecl_kw_get_ptr( nnc2_kw ) , ecl_kw_get_size( nnc2_kw ));
    int_vector_select_unique( nnc );
    test_assert_int_equal( int_vector_size( index_list ) , int_vector_size( nnc ));
    
    {
      int i;
      for (i=0; i < int_vector_size( nnc ); i++)
        test_assert_int_equal( int_vector_iget( nnc , i ) - 1 , int_vector_iget(index_list , i ));
    }
    int_vector_free( nnc );
  }
  
  ecl_file_close( gfile );
  ecl_grid_free( grid );

  exit(0);
}
コード例 #7
0
ファイル: eclxx_kw.cpp プロジェクト: Ensembles/ert
void test_resize() {
    ERT::EclKW< int > kw1( "short", 1 );

    test_assert_int_equal( kw1.size() , 1 );
    kw1.resize( 100 );
    test_assert_int_equal( kw1.size() , 100 );
}
コード例 #8
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);
}
コード例 #9
0
void test_active_index_list() {
  int default_value = -1;
  bool_vector_type * mask = bool_vector_alloc(0 , false);

  bool_vector_iset(mask , 10, true);
  bool_vector_iset(mask , 15, true);
  bool_vector_iset(mask , 20, true);

  {
    int_vector_type * active_index_list = bool_vector_alloc_active_index_list(mask , default_value);

    test_assert_int_equal( default_value , int_vector_get_default(active_index_list));
    test_assert_int_equal( 21 , int_vector_size( active_index_list ));

    test_assert_int_equal( default_value , int_vector_iget( active_index_list , 0));
    test_assert_int_equal( default_value , int_vector_iget( active_index_list , 1));
    test_assert_int_equal( default_value , int_vector_iget( active_index_list , 12));
    test_assert_int_equal( default_value , int_vector_iget( active_index_list , 19));

    test_assert_int_equal( 0 , int_vector_iget( active_index_list , 10));
    test_assert_int_equal( 1 , int_vector_iget( active_index_list , 15));
    test_assert_int_equal( 2 , int_vector_iget( active_index_list , 20));


    int_vector_free( active_index_list);
  }
  bool_vector_free(mask);
}
コード例 #10
0
void test_memcpy_from_data() {
  int_vector_type * int_vector = int_vector_alloc( 10 , 77 );
  int data[5] = {1,2,3,4,5};

  int_vector_memcpy_from_data( int_vector , data , 5 );
  test_assert_int_equal( 5 , int_vector_size( int_vector ));

  for (int i=0; i < int_vector_size( int_vector ); i++) 
    test_assert_int_equal( i + 1 , int_vector_iget( int_vector , i ));
  
  int_vector_free( int_vector );
}
コード例 #11
0
ファイル: enkf_state_map.c プロジェクト: andlaus/ResInsight
void set_test( ) {
  state_map_type * state_map = state_map_alloc();
  state_map_iset( state_map , 0 , STATE_INITIALIZED );
  test_assert_int_equal( STATE_INITIALIZED , state_map_iget( state_map , 0 ));

  state_map_iset( state_map , 100 , STATE_INITIALIZED );
  test_assert_int_equal( STATE_INITIALIZED , state_map_iget( state_map , 100 ));

  test_assert_int_equal( STATE_UNDEFINED , state_map_iget( state_map , 50 ));
  test_assert_int_equal( 101 , state_map_get_size( state_map ));
  state_map_free( state_map );
}
コード例 #12
0
void test_alloc() {
  const int size = 100;
  const int default_value = 77;
  int_vector_type * v = int_vector_alloc(size , default_value);

  test_assert_int_equal(size , int_vector_size(v));
  for (int i=0; i < size; i++)
    test_assert_int_equal( default_value , int_vector_iget( v , i));


  int_vector_free( v);
}
コード例 #13
0
ファイル: enkf_block_obs.c プロジェクト: blattms/ert
void test_create_from_field(ecl_grid_type * grid) {
  field_config_type * field_config = field_config_alloc_empty( "PRESSURE" , grid , NULL );
  block_obs_type * block_obs = block_obs_alloc( "ObsKey" , field_config , grid );
  
  test_assert_true( block_obs_is_instance( block_obs ));
  test_assert_int_equal(0 , block_obs_get_size( block_obs ));
  block_obs_append_field_obs( block_obs , 10 , 12 , 8  , 100 , 25);
  test_assert_int_equal(1 , block_obs_get_size( block_obs ));
  block_obs_append_field_obs( block_obs , 10 , 12 , 9  , 100 , 25);
  test_assert_int_equal(2 , block_obs_get_size( block_obs ));
  block_obs_free( block_obs );
  field_config_free( field_config );
}
コード例 #14
0
void test_init_case_job(ert_test_context_type * test_context, const char * job_name , const char * job_file) {
  stringlist_type * args = stringlist_alloc_new();
  enkf_main_type * enkf_main = ert_test_context_get_main(test_context);

  test_assert_true( ert_test_context_install_workflow_job( test_context , "JOB" , job_file ) );

  //Test init current case from existing
  {
    enkf_fs_type * cur_fs = enkf_main_mount_alt_fs( enkf_main , "new_current_case" , true );
    enkf_main_select_fs(enkf_main, "new_current_case");

    test_assert_ptr_not_equal(cur_fs , enkf_main_get_fs( enkf_main ));

    stringlist_append_copy( args, "default"); //case to init from
    test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args) );

    enkf_fs_decref(cur_fs);
  }

  {
    const char * current_case = enkf_main_get_current_fs( enkf_main );
    test_assert_string_equal(current_case, "new_current_case");
    test_assert_true(enkf_fs_has_node(enkf_main_get_fs(enkf_main), "PERMZ", PARAMETER, 0, 0, ANALYZED));

    enkf_fs_type * default_fs          = enkf_main_mount_alt_fs( enkf_main , "default" , true  );
    state_map_type * default_state_map = enkf_fs_get_state_map(default_fs);
    state_map_type * current_state_map = enkf_fs_get_state_map(enkf_main_get_fs(enkf_main));
    test_assert_int_equal(state_map_get_size(default_state_map), state_map_get_size(current_state_map));
    enkf_fs_decref(default_fs);
  }


  //Test init case from existing case:
  stringlist_clear(args);
  stringlist_append_copy(args, "default"); //case to init from
  stringlist_append_copy(args, "new_not_current_case");
  test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args) );
  {
    enkf_fs_type * fs = enkf_main_mount_alt_fs(enkf_main, "new_not_current_case", true);
    test_assert_not_NULL( fs );
    test_assert_true( enkf_fs_has_node(fs, "PERMZ", PARAMETER, 0, 0, ANALYZED ));

    enkf_fs_type * default_fs          = enkf_main_mount_alt_fs( enkf_main , "default" , true );
    state_map_type * default_state_map = enkf_fs_get_state_map(default_fs);
    state_map_type * new_state_map     = enkf_fs_get_state_map(fs);
    test_assert_int_equal(state_map_get_size(default_state_map), state_map_get_size(new_state_map));
    enkf_fs_decref(fs);
  }

  stringlist_free( args );
}
コード例 #15
0
int main(int argc , char ** argv) {
  const char * filename1 = argv[1];
  const char * filename2 = argv[2];
  const char * filename3 = argv[3];
  const char * filename4 = argv[4];

  int num_cpu = 4;
  test_assert_int_equal(ecl_util_get_num_cpu(filename1), num_cpu);
  test_assert_int_equal(ecl_util_get_num_cpu(filename2), num_cpu);
  test_assert_int_equal(ecl_util_get_num_cpu(filename3), num_cpu);
  test_assert_int_equal(ecl_util_get_num_cpu(filename4), num_cpu);
  exit(0);

}
コード例 #16
0
void test_idel_insert() {
  int_vector_type * vec = int_vector_alloc(0,0);

  int_vector_append(vec , 1 );
  int_vector_append(vec , 2 );
  int_vector_append(vec , 2 );
  int_vector_append(vec , 3 );

  int_vector_fprintf(vec , stdout , "Vec0" , "%2d");
  int_vector_idel(vec , 1 );
  int_vector_fprintf(vec , stdout , "Vec1" , "%2d");
  int_vector_idel(vec , 1 );
  int_vector_fprintf(vec , stdout , "Vec2" , "%2d");

  test_assert_int_equal( 2 , int_vector_size( vec ));
  test_assert_int_equal( 1 , int_vector_iget( vec , 0 ));
  test_assert_int_equal( 3 , int_vector_iget( vec , 1 ));

  int_vector_insert(vec , 1 , 2 );
  int_vector_insert(vec , 1 , 2 );
  test_assert_int_equal( 4 , int_vector_size( vec ));
  test_assert_int_equal( 1 , int_vector_iget( vec , 0 ));
  test_assert_int_equal( 2 , int_vector_iget( vec , 1 ));
  test_assert_int_equal( 2 , int_vector_iget( vec , 2 ));
  test_assert_int_equal( 3 , int_vector_iget( vec , 3 ));

  int_vector_free( vec );
}
コード例 #17
0
ファイル: enkf_state_map.c プロジェクト: andlaus/ResInsight
void test_update_undefined( ) {
  state_map_type * map = state_map_alloc( );
  
  state_map_iset( map , 10 , STATE_INITIALIZED );
  test_assert_int_equal( STATE_UNDEFINED , state_map_iget( map , 5 ) );
  test_assert_int_equal( STATE_INITIALIZED , state_map_iget( map , 10 ) );

  state_map_update_undefined( map , 5 , STATE_INITIALIZED );
  test_assert_int_equal( STATE_INITIALIZED , state_map_iget( map , 5 ) );
  
  state_map_update_undefined( map , 10 , STATE_INITIALIZED );
  test_assert_int_equal( STATE_INITIALIZED , state_map_iget( map , 10 ) );
  
  state_map_free( map );
}
コード例 #18
0
ファイル: well_state_load.c プロジェクト: agchitu/ert
int main(int argc , char ** argv) {
  test_install_SIGNALS();
  {
    const char * grid_file = argv[1];
    const char * rst_file_name = argv[2];

    ecl_grid_type * grid = ecl_grid_alloc( grid_file );
    ecl_file_type * rst_file = ecl_file_open( rst_file_name , 0);
    ecl_rsthead_type * header = ecl_rsthead_alloc( ecl_file_get_global_view( rst_file ) , ecl_util_filename_report_nr(rst_file_name) );
    const char * well_name = "WELL";
    int report_nr = 100;
    time_t valid_from = -1;
    bool open = false;
    well_type_enum type = ERT_GAS_INJECTOR;
    int global_well_nr = 0;
    bool load_segment_information = true;
    ecl_file_view_type * rst_view = ecl_file_get_global_view( rst_file );

    for (global_well_nr = 0; global_well_nr < header->nwells; global_well_nr++) {
      well_state_type * well_state = well_state_alloc(well_name , global_well_nr , open , type , report_nr , valid_from);
      test_assert_true( well_state_is_instance( well_state) );
      well_state_add_connections2( well_state , grid , rst_view , 0 );

      test_assert_true( well_state_has_grid_connections( well_state , ECL_GRID_GLOBAL_GRID ));
      test_assert_false( well_state_has_grid_connections( well_state , "???" ));
      test_assert_true( well_state_has_global_connections( well_state ));

      well_state_add_MSW2( well_state , rst_view , global_well_nr , load_segment_information );
      {
        const well_segment_collection_type * segments = well_state_get_segments( well_state );
        const well_branch_collection_type * branches = well_state_get_branches( well_state );

        if (well_state_is_MSW( well_state )) {
          test_assert_true( ecl_file_has_kw( rst_file , ISEG_KW ));
          test_assert_int_not_equal( well_segment_collection_get_size( segments ) , 0);
          test_assert_int_not_equal( well_branch_collection_get_size( branches ) , 0);
        } else {
          test_assert_int_equal( well_segment_collection_get_size( segments ) , 0);
          test_assert_int_equal( well_branch_collection_get_size( branches ) , 0);
          test_assert_false( well_state_is_MSW( well_state ));
        }
      }
      well_state_free( well_state );
    }
  }

  exit(0);
}
コード例 #19
0
ファイル: enkf_state_map.c プロジェクト: andlaus/ResInsight
void test_io( ) {
  test_work_area_type * work_area = test_work_area_alloc( "enkf-state-map" );
  {
    state_map_type * state_map = state_map_alloc();
    state_map_type * copy1 , *copy2;
    state_map_iset( state_map , 0 , STATE_INITIALIZED );
    state_map_iset( state_map , 100 , STATE_INITIALIZED );
    state_map_fwrite( state_map , "map");
    
    copy1 = state_map_fread_alloc( "map" );
    test_assert_true( state_map_equal( state_map , copy1 ));
    
    copy2 = state_map_alloc();
    state_map_fread( copy2 , "map" );
    test_assert_true( state_map_equal( state_map , copy2 ));

    state_map_iset( copy2 , 67 , STATE_INITIALIZED );
    test_assert_false(state_map_equal( state_map , copy2 ));
    
    state_map_fread( copy2 , "map");
    test_assert_true( state_map_equal( state_map , copy2 ));

    state_map_fread( copy2 , "DoesNotExis");
    test_assert_int_equal( 0 , state_map_get_size( copy2 ));
  }
  test_work_area_free( work_area );
}
コード例 #20
0
ファイル: enkf_analysis_config.c プロジェクト: danielfmva/ert
void test_min_realizations_percent(const char * num_realizations_str, const char * min_realizations_str, int min_realizations){
  test_work_area_type * work_area = test_work_area_alloc("test_min_realizations");

  {
    FILE * config_file_stream = util_mkdir_fopen("config_file", "w");
    test_assert_not_NULL(config_file_stream);
    fprintf(config_file_stream, num_realizations_str);
    fprintf(config_file_stream, min_realizations_str);
    fclose(config_file_stream);

    config_type * c = config_alloc();
    config_schema_item_type * item = config_add_schema_item(c , NUM_REALIZATIONS_KEY , true );
    config_schema_item_set_default_type(item, CONFIG_INT);
    config_schema_item_set_argc_minmax( item , 1 , 1);
    item = config_add_schema_item(c , MIN_REALIZATIONS_KEY , false );
    config_schema_item_set_argc_minmax( item , 1 , 2);
    test_assert_true(config_parse(c , "config_file" , "--" , NULL , NULL , false , true ));

    analysis_config_type * ac = create_analysis_config( );
    analysis_config_init(ac, c);

    test_assert_int_equal( min_realizations , analysis_config_get_min_realisations( ac ) );

    analysis_config_free( ac );
    config_free( c );
  }

  test_work_area_free(work_area);
}
コード例 #21
0
ファイル: ert_util_subst_list.c プロジェクト: Ensembles/ert
void test_filter_file1() {
  subst_list_type * subst_list = subst_list_alloc( NULL );
  test_work_area_type * work_area = test_work_area_alloc("subst_list/filter1");
  {
    FILE * stream = util_fopen("template" , "w");
    fprintf(stream , "<KEY1>\n<KEY2>\n<KEY3>\n<KEY4>\n");
    fclose(stream);
  }
  subst_list_append_copy( subst_list , "<KEY1>" , "Value1" , NULL);
  subst_list_append_copy( subst_list , "<KEY2>" , "Value2" , NULL);
  subst_list_append_copy( subst_list , "<KEY3>" , "Value3" , NULL);
  subst_list_append_copy( subst_list , "<KEY4>" , "Value4" , NULL);

  subst_list_filter_file( subst_list , "template" , "target");

  {
    FILE * stream = util_fopen("target" , "r");
    char s1[128],s2[128],s3[128],s4[128];

    test_assert_int_equal( 4 , fscanf( stream , "%s %s %s %s" , s1,s2,s3,s4));
    fclose(stream);

    test_assert_string_equal( s1 , "Value1");
    test_assert_string_equal( s2 , "Value2");
    test_assert_string_equal( s3 , "Value3");
    test_assert_string_equal( s4 , "Value4");
  }
  test_work_area_free( work_area );
  subst_list_free( subst_list );
}
コード例 #22
0
void test_correct_time_vector() {

  ecl_sum_type * ecl_sum = test_alloc_ecl_sum();
  time_t_vector_type * t = time_t_vector_alloc( 0 , 0 );
  time_t_vector_append(t, util_make_date_utc( 2,1,2010 ));
  time_t_vector_append(t, util_make_date_utc( 4,1,2010 ));
  time_t_vector_append(t, util_make_date_utc( 6,1,2010 ));
  time_t_vector_append(t, util_make_date_utc( 8,1,2010 ));
  ecl_sum_type * ecl_sum_resampled = ecl_sum_alloc_resample(ecl_sum, "kk", t);
  test_assert_int_equal(  ecl_sum_get_report_time(ecl_sum_resampled, 2)  , util_make_date_utc( 6,1,2010 ));

  const ecl_smspec_type * smspec_resampled = ecl_sum_get_smspec(ecl_sum_resampled);
  const smspec_node_type * node1 = ecl_smspec_iget_node(smspec_resampled, 1);
  const smspec_node_type * node2 = ecl_smspec_iget_node(smspec_resampled, 2);
  const smspec_node_type * node3 = ecl_smspec_iget_node(smspec_resampled, 3);
  test_assert_string_equal( "BPR" , smspec_node_get_keyword(node2) );
  test_assert_string_equal( "BARS" , smspec_node_get_unit(node2) );

  test_assert_double_equal(3.33333, ecl_sum_get_from_sim_time( ecl_sum_resampled, util_make_date_utc( 6,1,2010 ), node1) );
  test_assert_double_equal(3.33333, ecl_sum_get_from_sim_time( ecl_sum_resampled, util_make_date_utc( 2,1,2010 ), node2) );
  test_assert_double_equal(10.0000, ecl_sum_get_from_sim_time( ecl_sum_resampled, util_make_date_utc( 4,1,2010 ), node3) );


  ecl_sum_free(ecl_sum_resampled);
  time_t_vector_free(t);
  ecl_sum_free(ecl_sum);
}
コード例 #23
0
ファイル: eclxx_fortio.cpp プロジェクト: akva2/ert
void test_fortio_kw() {
    test_work_area_type * work_area = test_work_area_alloc("fortio_kw");
    ERT::EclKW<int> kw("XYZ" , 1000);
    for (size_t i =0 ; i < kw.size(); i++)
        kw[i] = i;

    {
        ERT::FortIO fortio("new_file" , std::fstream::out );
        kw.fwrite( fortio );
        fortio.close();
    }

    {
        ERT::FortIO fortio("new_file" , std::fstream::in );
        ERT::EclKW<int> kw2 = ERT::EclKW<int>::load( fortio );
        fortio.close( );
        for (size_t i =0 ; i < kw.size(); i++)
            test_assert_int_equal( kw[i] , kw2[i]);


        fortio = ERT::FortIO("new_file" , std::fstream::in );
	test_assert_throw( ERT::EclKW<float>::load(fortio) , std::invalid_argument );
        fortio.close();
    }

    test_work_area_free( work_area );
}
コード例 #24
0
ファイル: enkf_state_map.c プロジェクト: andlaus/ResInsight
void create_test() {
  state_map_type * state_map = state_map_alloc();
  test_assert_true( state_map_is_instance( state_map ));
  test_assert_int_equal( 0 , state_map_get_size( state_map ));
  test_assert_false( state_map_is_readonly( state_map ));
  state_map_free( state_map );
}
コード例 #25
0
ファイル: enkf_state_map.c プロジェクト: andlaus/ResInsight
void test_readonly() {
  {
    state_map_type * map1 = state_map_fread_alloc_readonly("FileDoesNotExist");
    
    test_assert_true(state_map_is_instance(map1));
    test_assert_int_equal(0 , state_map_get_size( map1 ));
    test_assert_true( state_map_is_readonly( map1 ));
    state_map_free(map1);
  }
  {
    test_work_area_type * work_area = test_work_area_alloc("state-map");
    state_map_type * map1 = state_map_alloc();
    
    state_map_iset(map1 , 5 , STATE_INITIALIZED);
    state_map_iset(map1 , 9 , STATE_INITIALIZED);

    state_map_fwrite(map1 , "map1");
    {
      state_map_type * map2 = state_map_fread_alloc_readonly("map1");
      
      test_assert_true(state_map_equal(map1 , map2));
      state_map_free(map2);
    }
    test_work_area_free( work_area );
    state_map_free(map1);
  }
}
コード例 #26
0
ファイル: enkf_state_map.c プロジェクト: andlaus/ResInsight
void test_deselect_matching( ) {
  state_map_type * map = state_map_alloc( );
  bool_vector_type * mask1 = bool_vector_alloc(0 , false);
  bool_vector_type * mask2 = bool_vector_alloc(1000 , true);

  state_map_iset( map , 10 , STATE_INITIALIZED );
  state_map_iset( map , 10 , STATE_HAS_DATA );
  state_map_iset( map , 20 , STATE_INITIALIZED );
  state_map_deselect_matching( map , mask1 , STATE_HAS_DATA | STATE_INITIALIZED );
  state_map_deselect_matching( map , mask2 , STATE_HAS_DATA | STATE_INITIALIZED );
  
  test_assert_int_equal( state_map_get_size( map ) , bool_vector_size( mask1 ));
  
  for (int i=0; i < bool_vector_size( mask1 ); i++) {
    if (i==10)
      test_assert_false( bool_vector_iget( mask1 , i ));
    else if (i== 20)
      test_assert_false( bool_vector_iget( mask2 , i ));
    else {
      test_assert_false( bool_vector_iget( mask1 , i ));
      test_assert_true( bool_vector_iget( mask2 , i ));
    }
  }
    
  bool_vector_free( mask1 );
  bool_vector_free( mask2 );
  state_map_free( map );
}
コード例 #27
0
ファイル: ert_util_work_area.cpp プロジェクト: OPM/ResInsight
void test_copy_parent_content( const char * path ) {
  char * full_path = util_alloc_abs_path( path );
  char * parent_path = util_alloc_parent_path( full_path );
  test_work_area_type * work_area = test_work_area_alloc( "copy-parent-content" );

  test_assert_false( test_work_area_copy_parent_content( work_area , "Does/not/exist") );
  test_assert_true( test_work_area_copy_parent_content( work_area , path ) );

  {

    struct dirent ** src_namelist;
    struct dirent ** target_namelist;
    int src_size    = scandir( parent_path                         , &src_namelist    , NULL , alphasort);
    int target_size = scandir( test_work_area_get_cwd( work_area ) , &target_namelist , NULL , alphasort);

    test_assert_int_equal( src_size , target_size );
    for (int i=0; i < src_size; i++) {
      test_assert_string_equal( src_namelist[i]->d_name , target_namelist[i]->d_name);

      free( src_namelist[i] );
      free( target_namelist[i] );
    }

    free( src_namelist );
    free( target_namelist );
  }
  free( parent_path );
  free( full_path );

  test_work_area_free( work_area );
}
コード例 #28
0
ファイル: ecl_coarse_test.c プロジェクト: Ensembles/ert
void test_coarse_cell(const ecl_grid_type * grid , ecl_coarse_cell_type * cell ) {
  const int_vector_type * global_index_list = ecl_coarse_cell_get_index_vector(cell );
  const int * ijk = ecl_coarse_cell_get_box_ptr( cell );
  int c;
  int prev_active = 0;

  for (c=0; c < ecl_coarse_cell_get_size( cell ); c++) {
    int gi = int_vector_iget( global_index_list , c );
    int i,j,k;

    /* The coordinates are right */
    ecl_grid_get_ijk1( grid , gi , &i , &j , &k);
    if ((i < ijk[0]) || (i > ijk[1]))
      test_error_exit("i:%d not inside range [%d,%d] \n",i , ijk[0] , ijk[1]); 

    if ((j < ijk[2]) || (j > ijk[3]))
      test_error_exit("j:%d not inside range [%d,%d] \n",j , ijk[2] , ijk[3]); 

    if ((k < ijk[4]) || (k > ijk[5]))
      test_error_exit("k:%d not inside range [%d,%d] \n",k , ijk[4] , ijk[4]); 

    if (c == 0)
      prev_active = ecl_grid_get_active_index1( grid , gi );
    else {
      /* All the cells have the same active value */
      int this_active = ecl_grid_get_active_index1( grid , gi );
      test_assert_int_equal( prev_active , this_active );
      prev_active = this_active;
    }
  }
}
コード例 #29
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 );
}
コード例 #30
0
ファイル: ecl_fault_block_layer.c プロジェクト: agchitu/ert
void test_create( const ecl_grid_type * grid , ecl_kw_type * fault_block_kw) {
  int k = 0;
  int i,j;
  
  for (j=0; j < ecl_grid_get_ny( grid ); j++) {
    for (i = 0; i < ecl_grid_get_nx( grid ); i++) {
      
      int g = ecl_grid_get_global_index3( grid , i,j,k);
      ecl_kw_iset_int( fault_block_kw , g , 9 );
    }
  }

  {
    fault_block_layer_type * layer = fault_block_layer_alloc( grid , k );
    test_assert_int_equal( 1 , fault_block_layer_get_next_id( layer ));
    fault_block_layer_scan_kw( layer , fault_block_kw);
    {
      fault_block_type * block = fault_block_layer_iget_block( layer , 0 );
      double x,y,z;
      ecl_grid_get_xyz3( grid , 4,4,k , &x, &y , &z );
      test_assert_double_equal( x , fault_block_get_xc( block ));
      test_assert_double_equal( y , fault_block_get_yc( block ));
    }
    
    fault_block_layer_free( layer );
  }
}