diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 6e9c2a63f3..5b41b996e3 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -141,10 +141,6 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn cell.setParentCellIndex(parentCellIndex); } - // Coarse cell info - ecl_coarse_cell_type * coarseCellData = ecl_grid_get_cell_coarse_group1( localEclGrid , localCellIdx); - cell.setInCoarseCell(coarseCellData != NULL); - // Corner coordinates int cIdx; for (cIdx = 0; cIdx < 8; ++cIdx) @@ -308,7 +304,8 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, activeCellInfo->setGridActiveCellCounts(0, globalMatrixActiveSize); fractureActiveCellInfo->setGridActiveCellCounts(0, globalFractureActiveSize); - + transferCoarseningInfo(mainEclGrid, mainGrid); + for (lgrIdx = 0; lgrIdx < numLGRs; ++lgrIdx) { @@ -327,6 +324,9 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, activeCellInfo->setGridActiveCellCounts(lgrIdx + 1, matrixActiveCellCount); fractureActiveCellInfo->setGridActiveCellCounts(lgrIdx + 1, fractureActiveCellCount); + + transferCoarseningInfo(localEclGrid, localGrid); + progInfo.setProgress(3 + lgrIdx); } @@ -1024,3 +1024,39 @@ std::vector RifReaderEclipseOutput::timeSteps() return m_timeSteps; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderEclipseOutput::transferCoarseningInfo(const ecl_grid_type* eclGrid, RigGridBase* grid) +{ + int coarseGroupCount = ecl_grid_get_num_coarse_groups(eclGrid); + for (int i = 0; i < coarseGroupCount; i++) + { + ecl_coarse_cell_type* coarse_cell = ecl_grid_iget_coarse_group(eclGrid, i); + CVF_ASSERT(coarse_cell); + + size_t i1 = static_cast(ecl_coarse_cell_get_i1(coarse_cell)); + size_t i2 = static_cast(ecl_coarse_cell_get_i2(coarse_cell)); + size_t j1 = static_cast(ecl_coarse_cell_get_j1(coarse_cell)); + size_t j2 = static_cast(ecl_coarse_cell_get_j2(coarse_cell)); + size_t k1 = static_cast(ecl_coarse_cell_get_k1(coarse_cell)); + size_t k2 = static_cast(ecl_coarse_cell_get_k2(coarse_cell)); + + size_t coarseningBoxIdx = grid->addCoarseningBox(i1, i2, j1, j2, k1, k2); + + for (size_t k = k1; k <= k2; k++) + { + for (size_t j = j1; j <= j2; j++) + { + for (size_t i = i1; i <= i2; i++) + { + size_t cellIdx = grid->cellIndexFromIJK(i, j, k); + RigCell c = grid->cell(cellIdx); + + c.setCoarseningBoxIndex(coarseningBoxIdx); + } + } + } + } +} + diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index 79bba123b6..5dc8794a3a 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -51,6 +51,7 @@ public: bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values); static bool transferGeometry(const ecl_grid_type* mainEclGrid, RigCaseData* eclipseCase); + static void transferCoarseningInfo(const ecl_grid_type* eclGrid, RigGridBase* grid); private: bool readActiveCellInfo(); diff --git a/ApplicationCode/ReservoirDataModel/RigCell.cpp b/ApplicationCode/ReservoirDataModel/RigCell.cpp index 7e0a83724d..6ddf5be8fa 100644 --- a/ApplicationCode/ReservoirDataModel/RigCell.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCell.cpp @@ -42,7 +42,7 @@ RigCell::RigCell() : m_hostGrid(NULL), m_isInvalid(false), m_cellIndex(cvf::UNDEFINED_SIZE_T), - m_isInCoarseCell(false) + m_coarseningBoxIndex(cvf::UNDEFINED_SIZE_T) { memcpy(m_cornerIndices.m_array, undefinedCornersArray, 8*sizeof(size_t)); diff --git a/ApplicationCode/ReservoirDataModel/RigCell.h b/ApplicationCode/ReservoirDataModel/RigCell.h index 7e920a3bdf..2929fd7ea1 100644 --- a/ApplicationCode/ReservoirDataModel/RigCell.h +++ b/ApplicationCode/ReservoirDataModel/RigCell.h @@ -54,8 +54,8 @@ public: size_t mainGridCellIndex() const { return m_mainGridCellIndex; } void setMainGridCellIndex(size_t mainGridCellContainingThisCell) { m_mainGridCellIndex = mainGridCellContainingThisCell; } - bool isInCoarseCell() const { return m_isInCoarseCell; } - void setInCoarseCell(bool isInCoarseCell) { m_isInCoarseCell = isInCoarseCell; } + size_t coarseningBoxIndex() const { return m_coarseningBoxIndex; } + void setCoarseningBoxIndex(size_t coarseningBoxIndex) { m_coarseningBoxIndex = coarseningBoxIndex; } void setCellFaceFault(cvf::StructGridInterface::FaceType face) { m_cellFaceFaults[face] = true; } bool isCellFaceFault(cvf::StructGridInterface::FaceType face) const { return m_cellFaceFaults[face]; } @@ -71,9 +71,10 @@ private: RigGridBase* m_hostGrid; RigLocalGrid* m_subGrid; - size_t m_parentCellIndex; ///< Grid cell index of the cell in the parent grid containing this cell + size_t m_parentCellIndex; ///< Grid cell index of the cell in the parent grid containing this cell size_t m_mainGridCellIndex; - bool m_isInCoarseCell; + + size_t m_coarseningBoxIndex; ///< If defined, index into list of coarsening boxes in RigGridBase bool m_cellFaceFaults[6]; diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index 97de8cdbd1..870afe0ff3 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -457,6 +457,42 @@ size_t RigGridBase::globalGridCellIndex(size_t localGridCellIndex) const return m_indexToStartOfCells + localGridCellIndex; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigGridBase::addCoarseningBox(size_t i1, size_t i2, size_t j1, size_t j2, size_t k1, size_t k2) +{ + caf::SizeTArray6 box; + box[0] = i1; + box[1] = i2; + box[2] = j1; + box[3] = j2; + box[4] = k1; + box[5] = k2; + + m_coarseningBoxInfo.push_back(box); + + return m_coarseningBoxInfo.size() - 1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigGridBase::coarseningBox(size_t coarseningBoxIndex, size_t* i1, size_t* i2, size_t* j1, size_t* j2, size_t* k1, size_t* k2) const +{ + CVF_ASSERT(coarseningBoxIndex < m_coarseningBoxInfo.size()); + + CVF_ASSERT(i1 && i2 && j1 && j2 && k1 && k2); + + caf::SizeTArray6 box = m_coarseningBoxInfo[coarseningBoxIndex]; + *i1 = box[0]; + *i2 = box[1]; + *j1 = box[2]; + *j2 = box[3]; + *k1 = box[4]; + *k2 = box[5]; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.h b/ApplicationCode/ReservoirDataModel/RigGridBase.h index 364de6ae10..eb9a71a5e2 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.h @@ -29,6 +29,7 @@ #include #include "cvfStructGridScalarDataAccess.h" #include "RifReaderInterface.h" +#include "cafFixedArray.h" class RigMainGrid; @@ -63,6 +64,9 @@ public: void computeFaults(); bool isMainGrid() const; RigMainGrid* mainGrid() const { return m_mainGrid; } + + size_t addCoarseningBox(size_t i1, size_t i2, size_t j1, size_t j2, size_t k1, size_t k2); + void coarseningBox(size_t coarseningBoxIndex, size_t* i1, size_t* i2, size_t* j1, size_t* j2, size_t* k1, size_t* k2) const; protected: friend class RigMainGrid;//::initAllSubGridsParentGridPointer(); @@ -101,6 +105,7 @@ private: size_t m_gridIndex; ///< The LGR index of this grid. Starts with 1. Main grid has index 0. RigMainGrid* m_mainGrid; + std::vector m_coarseningBoxInfo; }; diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 1088efd564..b5b70d6fba 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -540,12 +540,18 @@ public: hostCellJ.push_back(static_cast(pj + 1)); // NB: 1-based index in Octave hostCellK.push_back(static_cast(pk + 1)); // NB: 1-based index in Octave - // TODO: Handle coarse box concept - coarseBoxIdx.push_back(-1); + size_t coarseningIdx = globalCells[cIdx].coarseningBoxIndex(); + if (coarseningIdx != cvf::UNDEFINED_SIZE_T) + { + coarseBoxIdx.push_back(static_cast(coarseningIdx)); + } + else + { + coarseBoxIdx.push_back(-1); + } } } } - }; static bool RiaGetActiveCellInfo_init = RiaSocketCommandFactory::instance()->registerCreator(RiaGetActiveCellInfo::commandName()); diff --git a/cafProjectDataModel/cafFixedArray.h b/cafProjectDataModel/cafFixedArray.h index 4206af9709..40b9f14a76 100644 --- a/cafProjectDataModel/cafFixedArray.h +++ b/cafProjectDataModel/cafFixedArray.h @@ -40,6 +40,7 @@ typedef FixedArray IntArray4; typedef FixedArray IntArray8; typedef FixedArray SizeTArray3; typedef FixedArray SizeTArray4; +typedef FixedArray SizeTArray6; typedef FixedArray SizeTArray8; }