Exemple #1
0
//--------------------------------------------------------------------------------------------------
/// Find the cell index to the maingrid cell containing this cell, and store it as 
/// m_mainGridCellIndex in each cell.
//--------------------------------------------------------------------------------------------------
void RigGridBase::initSubCellsMainGridCellIndex()
{
    RigGridBase* grid = this;
    if (grid->isMainGrid())
    {
        size_t cellIdx;
        for (cellIdx = 0; cellIdx < grid->cellCount(); ++cellIdx)
        {
            RigCell& cell = grid->cell(cellIdx);
            cell.setMainGridCellIndex(cellIdx);
        }
    }
    else
    {
        size_t cellIdx;
        for (cellIdx = 0; cellIdx < grid->cellCount(); ++cellIdx)
        {
            RigLocalGrid* localGrid = NULL;
            RigGridBase* parentGrid = NULL;

            localGrid = static_cast<RigLocalGrid*>(grid);
            parentGrid = localGrid->parentGrid();

            RigCell& cell = localGrid->cell(cellIdx);
            size_t parentCellIndex = cell.parentCellIndex();

            while (!parentGrid->isMainGrid())
            {
                const RigCell& parentCell = parentGrid->cell(parentCellIndex);
                parentCellIndex = parentCell.parentCellIndex();

                localGrid = static_cast<RigLocalGrid*>(parentGrid);
                parentGrid = localGrid->parentGrid();
            }

            cell.setMainGridCellIndex(parentCellIndex);
        }
    }
}
Exemple #2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RigGridBase::initSubGridParentPointer()
{
    RigGridBase* grid = this;

    size_t cellIdx;
    for (cellIdx = 0; cellIdx < grid->cellCount(); ++cellIdx)
    {
        RigCell& cell = grid->cell(cellIdx);
        if (cell.subGrid())
        {
            cell.subGrid()->setParentGrid(grid);
        }
    }
}
    bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>&  args, QDataStream& socketStream) override
    {
        RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
        size_t argGridIndex = args[2].toUInt();

        if (!rimCase || !rimCase->eclipseCaseData() || (argGridIndex >= rimCase->eclipseCaseData()->gridCount()) )
        {
            // No data available
            socketStream << (quint64)0 << (quint64)0 << (quint64)0 << (quint64)0 << (quint64)0;
            return true;
        }

        RigGridBase* rigGrid = rimCase->eclipseCaseData()->grid(argGridIndex);

        quint64 cellCount  = (quint64)rigGrid->cellCount();
        quint64 cellCountI = (quint64)rigGrid->cellCountI();
        quint64 cellCountJ = (quint64)rigGrid->cellCountJ();
        quint64 cellCountK = (quint64)rigGrid->cellCountK();

        socketStream << cellCount;
        socketStream << cellCountI;
        socketStream << cellCountJ;
        socketStream << cellCountK;

        size_t doubleValueCount = cellCount * 3;
        quint64 byteCount = doubleValueCount * sizeof(double);
        socketStream << byteCount;

        // This structure is supposed to be received by Octave using a NDArray. The ordering of this loop is
        // defined by the ordering of the receiving NDArray
        //
        // See riGetCellCenters
        //
        //  dim_vector dv;
        //  dv.resize(4);
        //  dv(0) = cellCountI;
        //  dv(1) = cellCountJ;
        //  dv(2) = cellCountK;
        //  dv(3) = 3;

        size_t blockByteCount = cellCount * sizeof(double);
        std::vector<double> doubleValues(blockByteCount);

        for (int coordIdx = 0; coordIdx < 3; coordIdx++)
        {
            quint64 valueIndex = 0;

            for (size_t k = 0; k < cellCountK; k++)
            {
                for (size_t j = 0; j < cellCountJ; j++)
                {
                    for (size_t i = 0; i < cellCountI; i++)
                    {
                        size_t gridLocalCellIndex = rigGrid->cellIndexFromIJK(i, j, k);
                        cvf::Vec3d center = rigGrid->cell(gridLocalCellIndex).center();

                        convertVec3dToPositiveDepth(&center);

                        doubleValues[valueIndex++] = center[coordIdx];
                    }
                }
            }

            CVF_ASSERT(valueIndex == cellCount);

            RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)doubleValues.data(), blockByteCount);
        }

        return true;
    }