Пример #1
0
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);
}
Пример #2
0
void test_file( const char * filename , int occurence , bool exists , const ecl_rsthead_type * true_header) {
  int report_step = ecl_util_filename_report_nr( filename );
  ecl_file_type * rst_file = ecl_file_open( filename , 0);
  ecl_file_enum file_type = ecl_util_get_file_type( filename , NULL , NULL );
  ecl_file_view_type * rst_view;
  ecl_rsthead_type * rst_head;

  if (file_type == ECL_RESTART_FILE)
    rst_view = ecl_file_get_global_view( rst_file );
  else
    rst_view = ecl_file_get_restart_view( rst_file , occurence , -1 , -1 , -1 );

  if (exists) {
    test_assert_not_NULL( rst_view );
    rst_head = ecl_rsthead_alloc( rst_view , report_step);
    test_assert_not_NULL( rst_head );

    if (occurence == 0) {
      ecl_rsthead_type * rst_head0 = ecl_rsthead_alloc( rst_view , report_step );

      test_assert_true( ecl_rsthead_equal( rst_head , rst_head0 ));
      ecl_rsthead_free( rst_head0 );
    }
    test_assert_true( ecl_rsthead_equal( rst_head , true_header ));

    ecl_rsthead_free( rst_head );
  } else
    test_assert_NULL( rst_view );

}
Пример #3
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
ecl_kw_type* RifEclipseOutputFileTools::createActnumFromPorv(ecl_file_type* ecl_file)
{
    std::string porv_kw("PORV");

    if (ecl_file_has_kw(ecl_file, porv_kw.data()))
    {
        ecl_file_view_type* fileView = ecl_file_get_global_view(ecl_file);

        int keywordCount = ecl_file_get_num_named_kw(ecl_file, porv_kw.data());
        for (int index = 0; index < keywordCount; index++)
        {
            ecl_kw_type* fileKeyword = ecl_file_view_iget_named_kw(fileView, porv_kw.data(), index);
            if (fileKeyword)
            {
                float porvLimit = 0.0f;

                return ecl_kw_alloc_actnum(fileKeyword, porvLimit);
            }
        }
    }

    return nullptr;
}
Пример #4
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RifEclipseOutputFileTools::createReportStepsMetaData(std::vector<ecl_file_type*> ecl_files, std::vector<RifRestartReportStep>* reportSteps)
{
    if (!reportSteps) return;

    for (auto ecl_file : ecl_files)
    {
        if (!ecl_file) continue;

        int reportStepCount = ecl_file_get_num_named_kw(ecl_file, INTEHEAD_KW);
        for (int reportStepIndex = 0; reportStepIndex < reportStepCount; reportStepIndex++)
        {
            ecl_file_view_type* rst_view = ecl_file_get_global_view(ecl_file);
            if (!rst_view) continue;

            ecl_rsthead_type* restart_header = ecl_rsthead_alloc(rst_view, reportStepIndex);
            if (restart_header)
            {
                ecl_file_push_block(ecl_file);

                {
                    ecl_file_select_block(ecl_file, INTEHEAD_KW, reportStepIndex);

                    RifRestartReportStep reportStep;

                    // Set Date
                    {
                        QDateTime reportDateTime(QDate(restart_header->year, restart_header->month, restart_header->day));
                        reportStep.dateTime = reportDateTime;
                    }

                    // Find number of keywords withing this report step
                    int numKeywords = ecl_file_get_num_distinct_kw(ecl_file);
                    for (int iKey = 0; iKey < numKeywords; iKey++)
                    {
                        const char* kw = ecl_file_iget_distinct_kw(ecl_file, iKey);

                        int namedKeywordCount = ecl_file_get_num_named_kw(ecl_file, kw);
                        for (int iOcc = 0; iOcc < namedKeywordCount; iOcc++)
                        {
                            ecl_data_type dataType = ecl_file_iget_named_data_type(ecl_file, kw, iOcc);
                            ecl_type_enum dataTypeEmum = ecl_type_get_type(dataType);
                            if (dataTypeEmum != ECL_DOUBLE_TYPE && dataTypeEmum != ECL_FLOAT_TYPE && dataTypeEmum != ECL_INT_TYPE)
                            {
                                continue;
                            }

                            int itemCount = ecl_file_iget_named_size(ecl_file, kw, iOcc);
                            reportStep.m_keywords.appendKeyword(kw, itemCount, iOcc);
                        }
                    }

                    reportSteps->push_back(reportStep);
                }

                ecl_file_pop_block(ecl_file);

                ecl_rsthead_free(restart_header);
            }
        }
    }
}
Пример #5
0
int main(int argc , char ** argv) {
  const char * Xfile = argv[1];
  bool MSW;
  ecl_file_type * rst_file = ecl_file_open( Xfile , 0 );
  ecl_rsthead_type * rst_head = ecl_rsthead_alloc( ecl_file_get_global_view(rst_file) , ecl_util_filename_report_nr( Xfile ));
  
  test_install_SIGNALS();
  test_assert_true( util_sscanf_bool( argv[2] , &MSW ));
  test_assert_not_NULL( rst_file );
  test_assert_not_NULL( rst_head );
  
  {
    int iwell;
    const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 );
    const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 );
    ecl_kw_type * scon_kw = NULL;

    bool caseMSW = false;

    for (iwell = 0; iwell < rst_head->nwells; iwell++) {
      const int iwel_offset = rst_head->niwelz * iwell;
      int num_connections   = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_CONNECTIONS_INDEX );
      int iconn;
      well_conn_collection_type * wellcc = well_conn_collection_alloc( );
      well_conn_collection_type * wellcc_ref = well_conn_collection_alloc();

      for (iconn = 0; iconn < num_connections; iconn++) {
        well_conn_type * conn = well_conn_alloc_from_kw( icon_kw , scon_kw , rst_head , iwell , iconn );
        
        test_assert_true( well_conn_is_instance( conn ));
        test_assert_not_NULL( conn );
        if (!MSW)
          test_assert_bool_equal( well_conn_MSW( conn ) , MSW);
        else
          caseMSW |= well_conn_MSW( conn );
        
        well_conn_collection_add( wellcc , conn );
        well_conn_collection_add_ref( wellcc_ref , conn );
        test_assert_int_equal( iconn + 1 , well_conn_collection_get_size( wellcc ));
        test_assert_ptr_equal( well_conn_collection_iget_const( wellcc , iconn) , conn);
        test_assert_ptr_equal( well_conn_collection_iget_const( wellcc_ref , iconn) , conn);
      }
      well_conn_collection_free( wellcc_ref );
      {

        int i;
        for (i=0; i < well_conn_collection_get_size( wellcc ); i++)
          test_assert_true( well_conn_is_instance( well_conn_collection_iget_const( wellcc , i )));
        
      }
      {
        well_conn_collection_type * wellcc2 = well_conn_collection_alloc();
        int i;
        
        test_assert_int_equal( well_conn_collection_get_size( wellcc ) , 
                               well_conn_collection_load_from_kw( wellcc2 , iwel_kw , icon_kw , scon_kw , iwell , rst_head));
        
        for (i=0; i < well_conn_collection_get_size( wellcc2 ); i++) {
          test_assert_true( well_conn_is_instance( well_conn_collection_iget_const( wellcc2 , i )));
          test_assert_true( well_conn_equal( well_conn_collection_iget_const( wellcc2 , i ) , well_conn_collection_iget_const( wellcc , i )));
        }
        well_conn_collection_free( wellcc2 );
      }
      well_conn_collection_free( wellcc );
    }
    test_assert_bool_equal( caseMSW , MSW);
  }
  

  exit( 0 );
}
Пример #6
0
void well_info_add_UNRST_wells( well_info_type * well_info , ecl_file_type * rst_file, bool load_segment_information) {
  well_info_add_UNRST_wells2( well_info , ecl_file_get_global_view( rst_file ) , load_segment_information);
}
Пример #7
0
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( ecl_file_get_global_view(rst_file) , 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(ecl_file_get_global_view(rst_file));
  const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 );
  const ecl_kw_type * scon_kw = ecl_file_iget_named_kw( rst_file , SCON_KW , 0 );
  const ecl_kw_type * zwel_kw = ecl_file_iget_named_kw( rst_file , ZWEL_KW , 0 );

  { 
    int well_nr;
    for (well_nr = 0; well_nr < rst_head->nwells; well_nr++) {
      const int zwel_offset  = rst_head->nzwelz * well_nr;
      char * well_name       = util_alloc_strip_copy(ecl_kw_iget_ptr( zwel_kw , zwel_offset ));  
      
      printf("=================================================================\n");
      printf("Well: %s ",well_name);
      {
        well_conn_collection_type * connections = well_conn_collection_alloc();
        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();

          well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , scon_kw , well_nr , rst_head);
          well_segment_collection_link( segments );
          well_segment_collection_add_branches( segments , branches );
          well_segment_collection_add_connections( segments , ECL_GRID_GLOBAL_GRID , connections ); 
          
          printf("\n");
          printf("Segments:\n");
          {
            int is;
            for (is=0; is < well_segment_collection_get_size( segments ); is++) {
              well_segment_type * segment = well_segment_collection_iget( segments , is );
              printf("-----------------------------------------------------------------\n");
              printf("ID          : %d \n",well_segment_get_id( segment ));
              printf("Outlet      : %d \n",well_segment_get_outlet_id( segment ));
              printf("Branch      : %d \n",well_segment_get_branch_id( segment ));
              printf("Connections : [");
              {
                const well_conn_collection_type * connections = well_segment_get_global_connections( segment );
                if (connections) {
                  int ic;
                  for (ic = 0; ic < well_conn_collection_get_size( connections ); ic++) {
                    const well_conn_type * conn = well_conn_collection_iget( connections , ic );
                    printf("(%d , %d , %d)  ",well_conn_get_i( conn ), well_conn_get_j( conn ), well_conn_get_k( conn ));
                  }
                }
              }
              
              printf("]\n");
            }
          }
          well_branch_collection_free( branches );
        } else
          printf("not MSW well\n\n");

        well_conn_collection_free( connections );
        well_segment_collection_free( segments );
      }
    }
  }

  ecl_file_close( rst_file );
  ecl_rsthead_free( rst_head );
}