Esempio n. 1
0
ecl_nnc_geometry_type * ecl_nnc_geometry_alloc( const ecl_grid_type * grid ) {
  ecl_nnc_geometry_type * nnc_geo = (ecl_nnc_geometry_type*)util_malloc( sizeof * nnc_geo );
  UTIL_TYPE_ID_INIT( nnc_geo , ECL_NNC_GEOMETRY_TYPE_ID );
  nnc_geo->data = struct_vector_alloc( sizeof( struct ecl_nnc_pair_struct ));

  ecl_nnc_geometry_add_pairs( nnc_geo , grid );
  for (int lgr_index = 0; lgr_index < ecl_grid_get_num_lgr(grid); lgr_index++) {
    ecl_grid_type * igrid = ecl_grid_iget_lgr( grid , lgr_index );
    ecl_nnc_geometry_add_pairs( nnc_geo, igrid );
  }
  struct_vector_sort( nnc_geo->data , ecl_nnc_cmp );
  return nnc_geo;
}
Esempio n. 2
0
int main(int argc , char ** argv) {
  const char * grid_file = argv[1];
  ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_file );
  ecl_file_type * ecl_file = ecl_file_open( grid_file , 0);
  
  ecl_grid_test_lgr_consistency( ecl_grid );

  if (ecl_file_get_num_named_kw( ecl_file , COORD_KW ))
    test_assert_int_equal( ecl_file_get_num_named_kw( ecl_file , COORD_KW ) - 1, ecl_grid_get_num_lgr( ecl_grid ));
  
  ecl_grid_free( ecl_grid );
  ecl_file_close( ecl_file);
  exit(0);
}
Esempio n. 3
0
int  ecl_nnc_export( const ecl_grid_type * grid , const ecl_file_type * init_file , ecl_nnc_type * nnc_data) {
  int nnc_index = 0;
  int total_valid_trans = 0;
  total_valid_trans = ecl_nnc_export__( grid , 0 , init_file , nnc_data , &nnc_index );
  {
    int lgr_index;
    for (lgr_index = 0; lgr_index < ecl_grid_get_num_lgr(grid); lgr_index++) {
      ecl_grid_type * igrid = ecl_grid_iget_lgr( grid , lgr_index );
      total_valid_trans += ecl_nnc_export__( igrid , lgr_index , init_file , nnc_data , &nnc_index );
    }
  }
  nnc_index = ecl_nnc_export_get_size( grid );
  ecl_nnc_sort( nnc_data , nnc_index );
  return total_valid_trans;
}
Esempio n. 4
0
static void well_state_add_LGR_connections( well_state_type * well_state , const ecl_grid_type * grid , ecl_file_type * ecl_file, int global_well_nr ) {
  // Go through all the LGRs and add connections; both in the bulk
  // grid and as wellhead.
  int num_lgr = ecl_grid_get_num_lgr( grid );
  int lgr_index;
  for (lgr_index = 0; lgr_index < num_lgr; lgr_index++) {
    ecl_file_push_block( ecl_file );                                  // <-------------------------//
    {                                                                                              //
      ecl_file_subselect_block( ecl_file , LGR_KW , lgr_index );                                      //
      {                                                                                            //  Restrict the file view
        const char * grid_name = ecl_grid_iget_lgr_name( grid , lgr_index );                          //
        int well_nr = well_state_get_lgr_well_nr( well_state , ecl_file );                         //  to one LGR block.
        if (well_nr >= 0)                                                                          //
          well_state_add_connections__( well_state , ecl_file , grid_name , lgr_index + 1, well_nr ); //
      }                                                                                            //
    }                                                                                              //
    ecl_file_pop_block( ecl_file );                                   // <-------------------------//
  }
}
//--------------------------------------------------------------------------------------------------
/// Read geometry from file given by name into given reservoir object
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, RigReservoir* reservoir)
{
    CVF_ASSERT(reservoir);

    if (!mainEclGrid)
    {
        // Some error
        return false;
    }

    RigMainGrid* mainGrid = reservoir->mainGrid();
    {
        cvf::Vec3st  gridPointDim(0,0,0);
        gridPointDim.x() = ecl_grid_get_nx(mainEclGrid) + 1;
        gridPointDim.y() = ecl_grid_get_ny(mainEclGrid) + 1;
        gridPointDim.z() = ecl_grid_get_nz(mainEclGrid) + 1;
        mainGrid->setGridPointDimensions(gridPointDim);
    }

    // Get and set grid and lgr metadata

    size_t totalCellCount = static_cast<size_t>(ecl_grid_get_global_size(mainEclGrid));

    int numLGRs = ecl_grid_get_num_lgr(mainEclGrid);
    int lgrIdx;
    for (lgrIdx = 0; lgrIdx < numLGRs; ++lgrIdx)
    {
        ecl_grid_type* localEclGrid = ecl_grid_iget_lgr(mainEclGrid, lgrIdx);

        std::string lgrName = ecl_grid_get_name(localEclGrid);
        cvf::Vec3st  gridPointDim(0,0,0);
        gridPointDim.x() = ecl_grid_get_nx(localEclGrid) + 1;
        gridPointDim.y() = ecl_grid_get_ny(localEclGrid) + 1;
        gridPointDim.z() = ecl_grid_get_nz(localEclGrid) + 1;

        RigLocalGrid* localGrid = new RigLocalGrid(mainGrid);
        mainGrid->addLocalGrid(localGrid);

        localGrid->setIndexToStartOfCells(totalCellCount);
        localGrid->setGridName(lgrName);
        localGrid->setGridPointDimensions(gridPointDim);

        totalCellCount += ecl_grid_get_global_size(localEclGrid);
    }

    // Reserve room for the cells and nodes and fill them with data

    mainGrid->cells().reserve(totalCellCount);
    mainGrid->nodes().reserve(8*totalCellCount);

    caf::ProgressInfo progInfo(3 + numLGRs, "");
    progInfo.setProgressDescription("Main Grid");
    progInfo.setNextProgressIncrement(3);

    transferGridCellData(mainGrid, mainGrid, mainEclGrid, 0, 0);

    progInfo.setProgress(3);

    size_t globalMatrixActiveSize = ecl_grid_get_nactive(mainEclGrid);
    size_t globalFractureActiveSize = ecl_grid_get_nactive_fracture(mainEclGrid);

    mainGrid->setMatrixModelActiveCellCount(globalMatrixActiveSize);
    mainGrid->setFractureModelActiveCellCount(globalFractureActiveSize);

    for (lgrIdx = 0; lgrIdx < numLGRs; ++lgrIdx)
    {
        progInfo.setProgressDescription("LGR number " + QString::number(lgrIdx+1));

        ecl_grid_type* localEclGrid = ecl_grid_iget_lgr(mainEclGrid, lgrIdx);
        RigLocalGrid* localGrid = static_cast<RigLocalGrid*>(mainGrid->gridByIndex(lgrIdx+1));

        transferGridCellData(mainGrid, localGrid, localEclGrid, globalMatrixActiveSize, globalFractureActiveSize);

        int activeCellCount = ecl_grid_get_nactive(localEclGrid);
        localGrid->setMatrixModelActiveCellCount(activeCellCount);
        globalMatrixActiveSize += activeCellCount;

        activeCellCount = ecl_grid_get_nactive_fracture(localEclGrid);
        localGrid->setFractureModelActiveCellCount(activeCellCount);
        globalFractureActiveSize += activeCellCount;

        progInfo.setProgress(3 + lgrIdx);
    }


    mainGrid->setGlobalMatrixModelActiveCellCount(globalMatrixActiveSize);
    mainGrid->setGlobalFractureModelActiveCellCount(globalFractureActiveSize);

    return true;
}