Moved active cell computation from main grid to socket server

p4#: 20458
This commit is contained in:
Magne Sjaastad
2013-02-12 12:05:41 +01:00
parent 6101209d40
commit ea2c890b95
4 changed files with 92 additions and 85 deletions

View File

@@ -243,81 +243,6 @@ void RigMainGrid::computeCachedData()
computeBoundingBox(); computeBoundingBox();
} }
//--------------------------------------------------------------------------------------------------
///
///
///
//--------------------------------------------------------------------------------------------------
void RigMainGrid::calculateMatrixModelActiveCellInfo(std::vector<qint32> &gridNumber,
std::vector<qint32> &cellI,
std::vector<qint32> &cellJ,
std::vector<qint32> &cellK,
std::vector<qint32> &parentGridNumber,
std::vector<qint32> &hostCellI,
std::vector<qint32> &hostCellJ,
std::vector<qint32> &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<RigLocalGrid*>(grid))->parentGrid();
CVF_ASSERT(parentGrid != NULL);
parentGrid->ijkFromCellIndex(parentCellIdx, &pi, &pj, &pk);
}
gridNumber.push_back(static_cast<qint32>(grid->gridIndex()));
cellI.push_back(static_cast<qint32>(i));
cellJ.push_back(static_cast<qint32>(j));
cellK.push_back(static_cast<qint32>(k));
parentGridNumber.push_back(static_cast<qint32>(parentGrid->gridIndex()));
hostCellI.push_back(static_cast<qint32>(pi));
hostCellJ.push_back(static_cast<qint32>(pj));
hostCellK.push_back(static_cast<qint32>(pk));
}
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Returns the grid with index \a localGridIndex. Main Grid itself has index 0. First LGR starts on 1 /// Returns the grid with index \a localGridIndex. Main Grid itself has index 0. First LGR starts on 1
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -58,14 +58,6 @@ public:
RigGridBase* gridByIndex(size_t localGridIndex); RigGridBase* gridByIndex(size_t localGridIndex);
const RigGridBase* gridByIndex(size_t localGridIndex) const; const RigGridBase* gridByIndex(size_t localGridIndex) const;
void calculateMatrixModelActiveCellInfo(std::vector<qint32>& gridNumber,
std::vector<qint32>& i,
std::vector<qint32>& j,
std::vector<qint32>& k,
std::vector<qint32>& parentGridNumber,
std::vector<qint32>& hostCellI,
std::vector<qint32>& hostCellJ,
std::vector<qint32>& hostCellK);
void computeCachedData(); void computeCachedData();
cvf::BoundingBox matrixModelActiveCellsBoundingBox() const; cvf::BoundingBox matrixModelActiveCellsBoundingBox() const;

View File

@@ -368,8 +368,14 @@ void RiaSocketServer::readCommandFromOctave()
return; return;
} }
reservoir->reservoirData()->mainGrid()->calculateMatrixModelActiveCellInfo(activeCellInfo[0], activeCellInfo[1], activeCellInfo[2], activeCellInfo[3], calculateMatrixModelActiveCellInfo(activeCellInfo[0],
activeCellInfo[4], activeCellInfo[5], activeCellInfo[6], activeCellInfo[7]); activeCellInfo[1],
activeCellInfo[2],
activeCellInfo[3],
activeCellInfo[4],
activeCellInfo[5],
activeCellInfo[6],
activeCellInfo[7]);
// First write timestep count // First write timestep count
quint64 timestepCount = (quint64)8; quint64 timestepCount = (quint64)8;
@@ -611,3 +617,77 @@ void RiaSocketServer::slotReadyRead()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSocketServer::calculateMatrixModelActiveCellInfo(std::vector<qint32>& gridNumber, std::vector<qint32>& cellI, std::vector<qint32>& cellJ, std::vector<qint32>& cellK, std::vector<qint32>& parentGridNumber, std::vector<qint32>& hostCellI, std::vector<qint32>& hostCellJ, std::vector<qint32>& 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<RigCell>& 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<RigLocalGrid*>(grid))->parentGrid();
CVF_ASSERT(parentGrid != NULL);
parentGrid->ijkFromCellIndex(parentCellIdx, &pi, &pj, &pk);
}
gridNumber.push_back(static_cast<qint32>(grid->gridIndex()));
cellI.push_back(static_cast<qint32>(i));
cellJ.push_back(static_cast<qint32>(j));
cellK.push_back(static_cast<qint32>(k));
parentGridNumber.push_back(static_cast<qint32>(parentGrid->gridIndex()));
hostCellI.push_back(static_cast<qint32>(pi));
hostCellJ.push_back(static_cast<qint32>(pj));
hostCellK.push_back(static_cast<qint32>(pk));
}
}
}

View File

@@ -56,6 +56,16 @@ private:
RimReservoir* findReservoir(const QString &casename); RimReservoir* findReservoir(const QString &casename);
void terminateCurrentConnection(); void terminateCurrentConnection();
void calculateMatrixModelActiveCellInfo(std::vector<qint32>& gridNumber,
std::vector<qint32>& cellI,
std::vector<qint32>& cellJ,
std::vector<qint32>& cellK,
std::vector<qint32>& parentGridNumber,
std::vector<qint32>& hostCellI,
std::vector<qint32>& hostCellJ,
std::vector<qint32>& hostCellK);
private: private:
QTcpServer* m_tcpServer; QTcpServer* m_tcpServer;
QErrorMessage* m_errorMessageDialog; QErrorMessage* m_errorMessageDialog;