diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index d73b78f7e5..e1e97444be 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -243,81 +243,6 @@ void RigMainGrid::computeCachedData() computeBoundingBox(); } -//-------------------------------------------------------------------------------------------------- -/// -/// -/// -//-------------------------------------------------------------------------------------------------- -void RigMainGrid::calculateMatrixModelActiveCellInfo(std::vector &gridNumber, - std::vector &cellI, - std::vector &cellJ, - std::vector &cellK, - std::vector &parentGridNumber, - std::vector &hostCellI, - std::vector &hostCellJ, - std::vector &hostCellK) -{ - size_t numMatrixModelActiveCells = this->globalMatrixModelActiveCellCount(); - - gridNumber.clear(); - cellI.clear(); - cellJ.clear(); - cellK.clear(); - parentGridNumber.clear(); - hostCellI.clear(); - hostCellJ.clear(); - hostCellK.clear(); - - gridNumber.reserve(numMatrixModelActiveCells); - cellI.reserve(numMatrixModelActiveCells); - cellJ.reserve(numMatrixModelActiveCells); - cellK.reserve(numMatrixModelActiveCells); - parentGridNumber.reserve(numMatrixModelActiveCells); - hostCellI.reserve(numMatrixModelActiveCells); - hostCellJ.reserve(numMatrixModelActiveCells); - hostCellK.reserve(numMatrixModelActiveCells); - - for (size_t cIdx = 0; cIdx < m_cells.size(); ++cIdx) - { - if (m_cells[cIdx].isActiveInMatrixModel()) - { - RigGridBase* grid = m_cells[cIdx].hostGrid(); - CVF_ASSERT(grid != NULL); - size_t cellIndex = m_cells[cIdx].cellIndex(); - - size_t i, j, k; - grid->ijkFromCellIndex(cellIndex, &i, &j, &k); - - size_t pi, pj, pk; - RigGridBase* parentGrid = NULL; - - if (grid->isMainGrid()) - { - pi = i; - pj = j; - pk = k; - parentGrid = grid; - } - else - { - size_t parentCellIdx = m_cells[cIdx].parentCellIndex(); - parentGrid = (static_cast(grid))->parentGrid(); - CVF_ASSERT(parentGrid != NULL); - parentGrid->ijkFromCellIndex(parentCellIdx, &pi, &pj, &pk); - } - - gridNumber.push_back(static_cast(grid->gridIndex())); - cellI.push_back(static_cast(i)); - cellJ.push_back(static_cast(j)); - cellK.push_back(static_cast(k)); - parentGridNumber.push_back(static_cast(parentGrid->gridIndex())); - hostCellI.push_back(static_cast(pi)); - hostCellJ.push_back(static_cast(pj)); - hostCellK.push_back(static_cast(pk)); - } - } -} - //-------------------------------------------------------------------------------------------------- /// Returns the grid with index \a localGridIndex. Main Grid itself has index 0. First LGR starts on 1 //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.h b/ApplicationCode/ReservoirDataModel/RigMainGrid.h index aa9d19919f..fe73c4dd78 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.h @@ -58,14 +58,6 @@ public: RigGridBase* gridByIndex(size_t localGridIndex); const RigGridBase* gridByIndex(size_t localGridIndex) const; - void calculateMatrixModelActiveCellInfo(std::vector& gridNumber, - std::vector& i, - std::vector& j, - std::vector& k, - std::vector& parentGridNumber, - std::vector& hostCellI, - std::vector& hostCellJ, - std::vector& hostCellK); void computeCachedData(); cvf::BoundingBox matrixModelActiveCellsBoundingBox() const; diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 34991a9592..4dd668fd82 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -368,8 +368,14 @@ void RiaSocketServer::readCommandFromOctave() return; } - reservoir->reservoirData()->mainGrid()->calculateMatrixModelActiveCellInfo(activeCellInfo[0], activeCellInfo[1], activeCellInfo[2], activeCellInfo[3], - activeCellInfo[4], activeCellInfo[5], activeCellInfo[6], activeCellInfo[7]); + calculateMatrixModelActiveCellInfo(activeCellInfo[0], + activeCellInfo[1], + activeCellInfo[2], + activeCellInfo[3], + activeCellInfo[4], + activeCellInfo[5], + activeCellInfo[6], + activeCellInfo[7]); // First write timestep count quint64 timestepCount = (quint64)8; @@ -611,3 +617,77 @@ void RiaSocketServer::slotReadyRead() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSocketServer::calculateMatrixModelActiveCellInfo(std::vector& gridNumber, std::vector& cellI, std::vector& cellJ, std::vector& cellK, std::vector& parentGridNumber, std::vector& hostCellI, std::vector& hostCellJ, std::vector& hostCellK) +{ + gridNumber.clear(); + cellI.clear(); + cellJ.clear(); + cellK.clear(); + parentGridNumber.clear(); + hostCellI.clear(); + hostCellJ.clear(); + hostCellK.clear(); + + if (!m_currentReservoir || !m_currentReservoir->reservoirData() || !m_currentReservoir->reservoirData()->mainGrid()) + { + return; + } + + RigActiveCellInfo* actCellInfo = m_currentReservoir->reservoirData()->activeCellInfo(); + size_t numMatrixModelActiveCells = actCellInfo->globalMatrixModelActiveCellCount(); + + gridNumber.reserve(numMatrixModelActiveCells); + cellI.reserve(numMatrixModelActiveCells); + cellJ.reserve(numMatrixModelActiveCells); + cellK.reserve(numMatrixModelActiveCells); + parentGridNumber.reserve(numMatrixModelActiveCells); + hostCellI.reserve(numMatrixModelActiveCells); + hostCellJ.reserve(numMatrixModelActiveCells); + hostCellK.reserve(numMatrixModelActiveCells); + + const std::vector& globalCells = m_currentReservoir->reservoirData()->mainGrid()->cells(); + + for (size_t cIdx = 0; cIdx < globalCells.size(); ++cIdx) + { + if (actCellInfo->activeIndexInMatrixModel(cIdx)) + { + RigGridBase* grid = globalCells[cIdx].hostGrid(); + CVF_ASSERT(grid != NULL); + size_t cellIndex = globalCells[cIdx].cellIndex(); + + size_t i, j, k; + grid->ijkFromCellIndex(cellIndex, &i, &j, &k); + + size_t pi, pj, pk; + RigGridBase* parentGrid = NULL; + + if (grid->isMainGrid()) + { + pi = i; + pj = j; + pk = k; + parentGrid = grid; + } + else + { + size_t parentCellIdx = globalCells[cIdx].parentCellIndex(); + parentGrid = (static_cast(grid))->parentGrid(); + CVF_ASSERT(parentGrid != NULL); + parentGrid->ijkFromCellIndex(parentCellIdx, &pi, &pj, &pk); + } + + gridNumber.push_back(static_cast(grid->gridIndex())); + cellI.push_back(static_cast(i)); + cellJ.push_back(static_cast(j)); + cellK.push_back(static_cast(k)); + parentGridNumber.push_back(static_cast(parentGrid->gridIndex())); + hostCellI.push_back(static_cast(pi)); + hostCellJ.push_back(static_cast(pj)); + hostCellK.push_back(static_cast(pk)); + } + } +} + diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.h b/ApplicationCode/SocketInterface/RiaSocketServer.h index e6e0d54553..8a6f2e7e4e 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.h +++ b/ApplicationCode/SocketInterface/RiaSocketServer.h @@ -56,6 +56,16 @@ private: RimReservoir* findReservoir(const QString &casename); void terminateCurrentConnection(); + void calculateMatrixModelActiveCellInfo(std::vector& gridNumber, + std::vector& cellI, + std::vector& cellJ, + std::vector& cellK, + std::vector& parentGridNumber, + std::vector& hostCellI, + std::vector& hostCellJ, + std::vector& hostCellK); + + private: QTcpServer* m_tcpServer; QErrorMessage* m_errorMessageDialog;