Ejemplo n.º 1
0
void test_cells( const ecl_grid_type * grid ) {
  int error_count = 0;
  int global_index;
  for (global_index = 0; global_index < ecl_grid_get_global_size( grid ); global_index++) {
    if ((abs(ecl_grid_get_cell_volume1( grid , global_index)) + abs(ecl_grid_get_cell_volume1_tskille( grid , global_index))) > 1e-9) {
      if (!test_check_double_equal( ecl_grid_get_cell_volume1( grid , global_index) , ecl_grid_get_cell_volume1_tskille( grid , global_index))) {
        fprintf(stderr," Global index:%d \n",global_index);
        error_count += 1;
      }
    }
  }
  test_assert_int_equal(0 , error_count);
}
Ejemplo n.º 2
0
int main(int argc , char ** argv) {
  const char * path_case = argv[1];
  char * grid_file = ecl_util_alloc_filename( NULL , path_case , ECL_EGRID_FILE , false , 0 );
  char * init_file = ecl_util_alloc_filename( NULL , path_case , ECL_INIT_FILE , false , 0 );

  ecl_file_type * init = ecl_file_open( init_file , 0 );
  ecl_grid_type * grid = ecl_grid_alloc( grid_file );
  const ecl_kw_type * poro_kw = ecl_file_iget_named_kw( init , "PORO" , 0 );
  const ecl_kw_type * porv_kw = ecl_file_iget_named_kw( init , "PORV" , 0 );
  ecl_kw_type * multpv = NULL;
  ecl_kw_type * NTG = NULL;
  bool error_found = false;

  double total_volume = 0;
  double total_diff = 0;
  int error_count = 0;
  int iactive;

  if (ecl_file_has_kw( init , "NTG"))
    NTG = ecl_file_iget_named_kw( init , "NTG" , 0);

  if (ecl_file_has_kw( init , "MULTPV"))
    multpv = ecl_file_iget_named_kw( init , "MULTPV" , 0);

  for (iactive = 0; iactive < ecl_grid_get_nactive( grid ); ++iactive) {
    int iglobal = ecl_grid_get_global_index1A( grid , iactive );
    double grid_volume = ecl_grid_get_cell_volume1( grid , iglobal );
    double eclipse_volume = ecl_kw_iget_float( porv_kw , iglobal ) / ecl_kw_iget_float( poro_kw , iactive );

    if (NTG)
      eclipse_volume /= ecl_kw_iget_float( NTG , iactive );

    if (multpv)
      eclipse_volume *= ecl_kw_iget_float( multpv , iactive);

    total_volume += grid_volume;
    total_diff += fabs( eclipse_volume - grid_volume );
    if (!util_double_approx_equal__( grid_volume , eclipse_volume , 2.5e-3, 0.00)) {
      double diff = 100 * (grid_volume - eclipse_volume) / eclipse_volume;
      printf("Error in cell: %d V1: %g    V2: %g   diff:%g %% \n", iglobal , grid_volume , eclipse_volume , diff);
      error_count++;
      error_found = true;
    }
  }
  printf("Total volume difference: %g %% \n", 100 * total_diff / total_volume );



  ecl_grid_free( grid );
  ecl_file_close( init );
  free( grid_file );
  free( init_file );
  if (error_found) {
    printf("Error_count: %d / %d \n",error_count , ecl_grid_get_nactive( grid ));
    exit(1);
  }  else
    exit(0);
}
Ejemplo n.º 3
0
void IntegrationTest::setCellVolumes() {
    double absTolerance = getAbsTolerance();
    double relTolerance = getRelTolerance();
    const unsigned int globalGridCount1 = ecl_grid_get_global_size(ecl_grid1);
    const unsigned int activeGridCount1 = ecl_grid_get_active_size(ecl_grid1);
    const unsigned int globalGridCount2 = ecl_grid_get_global_size(ecl_grid2);
    const unsigned int activeGridCount2 = ecl_grid_get_active_size(ecl_grid2);
    if (globalGridCount1 != globalGridCount2) {
        OPM_THROW(std::runtime_error, "In grid file:"
                << "\nCells in first file: "  << globalGridCount1
                << "\nCells in second file: " << globalGridCount2
                << "\nThe number of global cells differ.");
    }
    if (activeGridCount1 != activeGridCount2) {
        OPM_THROW(std::runtime_error, "In grid file:"
                << "\nCells in first file: "  << activeGridCount1
                << "\nCells in second file: " << activeGridCount2
                << "\nThe number of active cells differ.");
    }
    for (unsigned int cell = 0; cell < globalGridCount1; ++cell) {
        const double cellVolume1 = ecl_grid_get_cell_volume1(ecl_grid1, cell);
        const double cellVolume2 = ecl_grid_get_cell_volume1(ecl_grid2, cell);
        Deviation dev = calculateDeviations(cellVolume1, cellVolume2);
        if (dev.abs > absTolerance && dev.rel > relTolerance) {
            int i, j, k;
            ecl_grid_get_ijk1(ecl_grid1, cell, &i, &j, &k);
            // Coordinates from this function are zero-based, hence incrementing
            i++, j++, k++;
            OPM_THROW(std::runtime_error, "In grid file: Deviations of cell volume exceed tolerances. "
                    << "\nFor cell with coordinate (" << i << ", " << j << ", " << k << "):"
                    << "\nCell volume in first file: "  << cellVolume1
                    << "\nCell volume in second file: " << cellVolume2
                    << "\nThe absolute deviation is " << dev.abs << ", and the tolerance limit is " << absTolerance << "."
                    << "\nThe relative deviation is " << dev.rel << ", and the tolerance limit is " << relTolerance << ".");
        } // The second input case is used as reference.
        cellVolumes.push_back(cellVolume2);
    }
}
Ejemplo n.º 4
0
static void ecl_init_file_fwrite_poro( fortio_type * fortio , const ecl_grid_type * ecl_grid , const ecl_kw_type * poro ) {
  {
    ecl_kw_type * porv = ecl_kw_alloc( PORV_KW , ecl_grid_get_global_size( ecl_grid ) , ECL_FLOAT_TYPE);
    int global_index;
    bool global_poro = (ecl_kw_get_size( poro ) == ecl_grid_get_global_size( ecl_grid )) ? true : false;
    for ( global_index = 0; global_index < ecl_grid_get_global_size( ecl_grid ); global_index++) {
      int active_index = ecl_grid_get_active_index1( ecl_grid , global_index );
      if (active_index >= 0) {
        int poro_index = global_poro ? global_index : active_index;
        ecl_kw_iset_float( porv , global_index , ecl_kw_iget_float( poro , poro_index ) * ecl_grid_get_cell_volume1( ecl_grid , global_index ));
      } else
        ecl_kw_iset_float( porv , global_index , 0 );
    }
    ecl_kw_fwrite( porv , fortio );
    ecl_kw_free( porv );
  }

  ecl_kw_fwrite( poro , fortio );
}