Esempio n. 1
0
bool fault_block_layer_scan_kw( fault_block_layer_type * layer , const ecl_kw_type * fault_block_kw) {
  bool assign_zero = true;

  if (ecl_kw_get_size( fault_block_kw) != ecl_grid_get_global_size(layer->grid))
    return false;
  else if (!ecl_type_is_int(ecl_kw_get_data_type( fault_block_kw )))
    return false;
  else {
    int i,j;
    int max_block_id = 0;
    layer_type * work_layer = layer_alloc( ecl_grid_get_nx( layer->grid ) , ecl_grid_get_ny( layer->grid ));

    for (j=0; j < ecl_grid_get_ny( layer->grid ); j++) {
      for (i=0; i < ecl_grid_get_nx( layer->grid ); i++) {
        int g = ecl_grid_get_global_index3( layer->grid , i , j , layer->k );
        int block_id = ecl_kw_iget_int( fault_block_kw , g );


        if (block_id > 0) {
          layer_iset_cell_value( work_layer , i , j , block_id );
          max_block_id = util_int_max( block_id , max_block_id );
        }
      }
    }

    if (assign_zero)
      layer_replace_cell_values( work_layer , 0 , max_block_id + 1);

    fault_block_layer_scan_layer( layer , work_layer );
    layer_free( work_layer );
    return true;
  }
}
Esempio n. 2
0
void test_create( const ecl_grid_type * grid , ecl_kw_type * fault_block_kw) {
  int k = 0;
  int i,j;
  
  for (j=0; j < ecl_grid_get_ny( grid ); j++) {
    for (i = 0; i < ecl_grid_get_nx( grid ); i++) {
      
      int g = ecl_grid_get_global_index3( grid , i,j,k);
      ecl_kw_iset_int( fault_block_kw , g , 9 );
    }
  }

  {
    fault_block_layer_type * layer = fault_block_layer_alloc( grid , k );
    test_assert_int_equal( 1 , fault_block_layer_get_next_id( layer ));
    fault_block_layer_scan_kw( layer , fault_block_kw);
    {
      fault_block_type * block = fault_block_layer_iget_block( layer , 0 );
      double x,y,z;
      ecl_grid_get_xyz3( grid , 4,4,k , &x, &y , &z );
      test_assert_double_equal( x , fault_block_get_xc( block ));
      test_assert_double_equal( y , fault_block_get_yc( block ));
    }
    
    fault_block_layer_free( layer );
  }
}
Esempio n. 3
0
bool fault_block_layer_load_kw( fault_block_layer_type * layer , const ecl_kw_type * fault_block_kw) {
  if (ecl_kw_get_size( fault_block_kw) != ecl_grid_get_global_size(layer->grid))
    return false;
  else if (!ecl_type_is_int(ecl_kw_get_data_type( fault_block_kw )))
    return false;
  else {
    int i,j;

    for (j=0; j < ecl_grid_get_ny( layer->grid ); j++) {
      for (i=0; i < ecl_grid_get_nx( layer->grid ); i++) {
        int g = ecl_grid_get_global_index3( layer->grid , i , j , layer->k );
        int block_id = ecl_kw_iget_int( fault_block_kw , g );
        if (block_id > 0) {
          fault_block_layer_add_block( layer , block_id );
          {
            fault_block_type * fault_block = fault_block_layer_get_block( layer , block_id );
            fault_block_add_cell( fault_block , i,j );
          }
        }
      }
    }

    return true;
  }
}
Esempio n. 4
0
void layer_update_active( layer_type * layer , const ecl_grid_type * grid , int k) {
  int i,j;
  for (j=0; j< ecl_grid_get_ny( grid ); j++) {
    for (i=0; i < ecl_grid_get_nx( grid ); i++) {
      cell_type * cell = layer_iget_cell( layer , i , j );
      cell->active = ecl_grid_cell_active3( grid , i , j , k );
    }
  }
}
Esempio n. 5
0
bool fault_block_layer_export( const fault_block_layer_type * layer , ecl_kw_type * faultblock_kw) {
  if (ecl_type_is_int(ecl_kw_get_data_type( faultblock_kw )) && (ecl_kw_get_size( faultblock_kw ) == ecl_grid_get_global_size( layer->grid ))) {
    int i,j;

    for (j=0; j < ecl_grid_get_ny( layer->grid ); j++) {
      for (i=0; i < ecl_grid_get_nx( layer->grid ); i++) {
        int g = ecl_grid_get_global_index3( layer->grid , i, j , layer->k );
        int cell_value = layer_iget_cell_value( layer->layer , i , j );
        ecl_kw_iset_int( faultblock_kw , g , cell_value);
      }
    }
    return true;
  } else
    return false;
}
Esempio n. 6
0
fault_block_layer_type * fault_block_layer_alloc( const ecl_grid_type * grid , int k) {
  if ((k < 0) || (k >= ecl_grid_get_nz( grid )))
    return NULL;
  else {
    fault_block_layer_type * layer = (fault_block_layer_type*)util_malloc( sizeof * layer );
    UTIL_TYPE_ID_INIT( layer , FAULT_BLOCK_LAYER_ID);
    layer->grid = grid;
    layer->k    = k;
    layer->block_map = int_vector_alloc( 0 , -1);
    layer->blocks = vector_alloc_new();
    layer->layer = layer_alloc(ecl_grid_get_nx(grid) , ecl_grid_get_ny(grid));

    return layer;
  }
}
Esempio n. 7
0
static ecl_kw_type * ecl_init_file_alloc_INTEHEAD( const ecl_grid_type * ecl_grid , int phases, time_t start_date , int simulator) {
  ecl_kw_type * intehead_kw = ecl_kw_alloc( INTEHEAD_KW , INTEHEAD_INIT_SIZE , ECL_INT_TYPE );
  ecl_kw_scalar_set_int( intehead_kw , 0 );

  ecl_kw_iset_int( intehead_kw , INTEHEAD_UNIT_INDEX    , INTEHEAD_METRIC_VALUE );
  ecl_kw_iset_int( intehead_kw , INTEHEAD_NX_INDEX      , ecl_grid_get_nx( ecl_grid ));
  ecl_kw_iset_int( intehead_kw , INTEHEAD_NY_INDEX      , ecl_grid_get_ny( ecl_grid ));
  ecl_kw_iset_int( intehead_kw , INTEHEAD_NZ_INDEX      , ecl_grid_get_nz( ecl_grid ));
  ecl_kw_iset_int( intehead_kw , INTEHEAD_NACTIVE_INDEX , ecl_grid_get_active_size( ecl_grid ));
  ecl_kw_iset_int( intehead_kw , INTEHEAD_PHASE_INDEX   , phases );
  {
    int mday,month,year;
    ecl_util_set_date_values( start_date , &mday , &month , &year );
    ecl_kw_iset_int( intehead_kw , INTEHEAD_DAY_INDEX    , mday );
    ecl_kw_iset_int( intehead_kw , INTEHEAD_MONTH_INDEX  , month );
    ecl_kw_iset_int( intehead_kw , INTEHEAD_YEAR_INDEX   , year );
  }
  ecl_kw_iset_int( intehead_kw , INTEHEAD_IPROG_INDEX , simulator);

  return intehead_kw;
}
//--------------------------------------------------------------------------------------------------
/// 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;
}