Exemple #1
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);
}
void test_load() {
  test_work_area_type * work_area = test_work_area_alloc("unsmry_loader");
  ecl_sum_type * ecl_sum = write_ecl_sum();
  test_assert_true( util_file_exists("CASE.SMSPEC") );
  test_assert_true( util_file_exists("CASE.UNSMRY") );
  ecl::unsmry_loader * loader = new ecl::unsmry_loader(ecl_sum_get_smspec(ecl_sum), "CASE.UNSMRY", 0);

  const std::vector<double> FOPT_value = loader->get_vector(1);
  const std::vector<double> BPR_value  = loader->get_vector(2);
  const std::vector<double> WWCT_value = loader->get_vector(3);
  test_assert_int_equal( FOPT_value.size(), 4 );
  test_assert_double_equal( FOPT_value[3] , 6.0 );
  test_assert_double_equal( BPR_value[2]  , 10.0 );
  test_assert_double_equal( WWCT_value[1] , 10.0 );

  delete loader;
  ecl_sum_free(ecl_sum);
  test_work_area_free(work_area);
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseSummary::open(const std::string& headerFileName, const std::vector<std::string>& dataFileNames)
{
    assert(ecl_sum == NULL); 
    
    if (headerFileName.empty() || dataFileNames.size() == 0) return false;

    assert(!headerFileName.empty());
    assert(dataFileNames.size() > 0);

    stringlist_type* dataFiles = stringlist_alloc_new();
    for (size_t i = 0; i < dataFileNames.size(); i++)
    {
        stringlist_append_copy(dataFiles, dataFileNames[i].data());
    }

    std::string itemSeparatorInVariableNames = ":";
    ecl_sum = ecl_sum_fread_alloc(headerFileName.data(), dataFiles, itemSeparatorInVariableNames.data());

    stringlist_free(dataFiles);

    if (ecl_sum)
    {
        eclSmSpec = ecl_sum_get_smspec(ecl_sum);
        assert(eclSmSpec != NULL);

        assert(ecl_sum != NULL);

        for ( int time_index = 0; time_index < timeStepCount(); time_index++ )
        {
            time_t sim_time = ecl_sum_iget_sim_time(ecl_sum, time_index);
            m_timeSteps.push_back(sim_time);
        }

        return true;
    }

    return false;
}