Exemplo n.º 1
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 );
}
Exemplo n.º 2
0
void EclipseIO::Impl::writeEGRIDFile( const NNC& nnc ) const {
    const auto& ioConfig = this->es.getIOConfig();

    std::string  egridFile( ERT::EclFilename( this->outputDir,
                                              this->baseName,
                                              ECL_EGRID_FILE,
                                              ioConfig.getFMTOUT() ));

    {
        int idx = 0;
        auto* ecl_grid = const_cast< ecl_grid_type* >( this->grid.c_ptr() );
        for (const NNCdata& n : nnc.nncdata())
            ecl_grid_add_self_nnc( ecl_grid, n.cell1, n.cell2, idx++);

        ecl_grid_fwrite_EGRID2(ecl_grid, egridFile.c_str(), this->es.getDeckUnitSystem().getEclType() );
    }
}