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 ); }
int main(int argc , char ** argv) { const char * Xfile = argv[1]; ecl_file_type * rst_file = ecl_file_open( Xfile , 0 ); ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_file ); const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 ); const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0 ); const ecl_kw_type * rseg_kw = ecl_file_iget_named_kw( rst_file , RSEG_KW , 0 ); const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 ); test_install_SIGNALS(); test_assert_not_NULL( rst_file ); test_assert_not_NULL( rst_head ); { int well_nr; for (well_nr = 0; well_nr < rst_head->nwells; well_nr++) { well_conn_collection_type * connections = well_conn_collection_alloc(); well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , well_nr , rst_head); { well_segment_collection_type * segments = well_segment_collection_alloc(); if (well_segment_collection_load_from_kw( segments , well_nr , iwel_kw , iseg_kw , rseg_kw , rst_head )) { well_branch_collection_type * branches = well_branch_collection_alloc(); test_assert_true( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head)); well_segment_collection_link( segments ); { int is; for (is=0; is < well_segment_collection_get_size( segments ); is++) { well_segment_type * segment = well_segment_collection_iget( segments , is ); if (well_segment_nearest_wellhead( segment )) test_assert_NULL( well_segment_get_outlet( segment )); else test_assert_not_NULL( well_segment_get_outlet( segment )); test_assert_ptr_not_equal( segment , well_segment_get_outlet( segment )); } } well_segment_collection_add_branches( segments , branches ); { int ib; for (ib = 0; ib < well_branch_collection_get_size( branches ); ib++) { const well_segment_type * start_segment = well_branch_collection_iget_start_segment( branches , ib ); const well_segment_type * segment = start_segment; printf("Branch %d/%d " , ib , well_branch_collection_get_size( branches ) ); while (segment) { printf("[%p]%d -> \n",segment , well_segment_get_id( segment )); segment = well_segment_get_outlet( segment ); } printf("\n"); sleep(1); } } well_segment_collection_add_connections( segments , ECL_GRID_GLOBAL_GRID , connections ); well_branch_collection_free( branches ); } else test_assert_false( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head )); well_segment_collection_free( segments ); } well_conn_collection_free( connections ); } } ecl_file_close( rst_file ); ecl_rsthead_free( rst_head ); exit(0); }
int main(int argc , char ** argv) { const char * Xfile = argv[1]; ecl_file_type * rst_file = ecl_file_open( Xfile , 0 ); ecl_file_view_type * rst_view = ecl_file_get_active_view( rst_file ); ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_view , ecl_util_filename_report_nr(Xfile)); const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 ); const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0 ); well_rseg_loader_type * rseg_loader = well_rseg_loader_alloc(rst_view); const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 ); const ecl_kw_type * scon_kw = NULL; const ecl_kw_type * xcon_kw = NULL; test_install_SIGNALS(); test_assert_not_NULL( rst_file ); test_assert_not_NULL( rst_head ); { int well_nr; for (well_nr = 0; well_nr < rst_head->nwells; well_nr++) { well_conn_collection_type * connections = well_conn_collection_alloc(); well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , scon_kw, xcon_kw, well_nr , rst_head); { well_segment_collection_type * segments = well_segment_collection_alloc(); bool load_segment_information = true; bool is_MSW_well = false; if (well_segment_collection_load_from_kw( segments , well_nr , iwel_kw , iseg_kw , rseg_loader , rst_head , load_segment_information , &is_MSW_well)) { well_branch_collection_type * branches = well_branch_collection_alloc(); test_assert_true( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head)); well_segment_collection_link( segments ); { int is; for (is=0; is < well_segment_collection_get_size( segments ); is++) { well_segment_type * segment = well_segment_collection_iget( segments , is ); if (well_segment_nearest_wellhead( segment )) test_assert_NULL( well_segment_get_outlet( segment )); else test_assert_not_NULL( well_segment_get_outlet( segment )); test_assert_int_not_equal( well_segment_get_id( segment ) , well_segment_get_outlet_id( segment )); test_assert_ptr_not_equal( segment , well_segment_get_outlet( segment )); } } well_segment_collection_add_branches( segments , branches ); { int ib; for (ib = 0; ib < well_branch_collection_get_size( branches ); ib++) { const well_segment_type * start_segment = well_branch_collection_iget_start_segment( branches , ib ); const well_segment_type * segment = start_segment; printf("Branch %d " , ib ); while (segment) { printf("%d -> ",well_segment_get_id( segment )); segment = well_segment_get_outlet( segment ); } printf(" X \n"); } } well_segment_collection_add_connections( segments , ECL_GRID_GLOBAL_GRID , connections ); well_branch_collection_free( branches ); } else test_assert_false( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head )); well_segment_collection_free( segments ); } well_conn_collection_free( connections ); } } ecl_file_close( rst_file ); ecl_rsthead_free( rst_head ); exit(0); }