mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
@@ -3,36 +3,36 @@
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron AS
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaSocketCommand.h"
|
||||
|
||||
#include "RiaSocketServer.h"
|
||||
#include "RiaSocketTools.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaSocketServer.h"
|
||||
#include "RiaSocketTools.h"
|
||||
|
||||
#include "RigActiveCellInfo.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigFemPart.h"
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigFemPartGrid.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
#include "RigMainGrid.h"
|
||||
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimCellEdgeColors.h"
|
||||
@@ -52,22 +52,21 @@
|
||||
|
||||
#include <array>
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// OBSOLETE, to be deleted
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetMainGridDimensions: public RiaSocketCommand
|
||||
class RiaGetMainGridDimensions : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetMainGridDimensions"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
return QString( "GetMainGridDimensions" );
|
||||
}
|
||||
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
if (!rimCase) return true;
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs( server, args );
|
||||
if ( !rimCase ) return true;
|
||||
|
||||
// Write data back to octave: I, J, K dimensions
|
||||
|
||||
@@ -75,7 +74,7 @@ public:
|
||||
size_t jCount = 0;
|
||||
size_t kCount = 0;
|
||||
|
||||
if (rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid())
|
||||
if ( rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid() )
|
||||
{
|
||||
iCount = rimCase->eclipseCaseData()->mainGrid()->cellCountI();
|
||||
jCount = rimCase->eclipseCaseData()->mainGrid()->cellCountJ();
|
||||
@@ -88,29 +87,31 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetMainGridDimensions_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetMainGridDimensions>(RiaGetMainGridDimensions::commandName());
|
||||
|
||||
|
||||
static bool RiaGetMainGridDimensions_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetMainGridDimensions>(
|
||||
RiaGetMainGridDimensions::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetActiveCellInfo: public RiaSocketCommand
|
||||
class RiaGetActiveCellInfo : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetActiveCellInfo"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
if (!rimCase) return true;
|
||||
return QString( "GetActiveCellInfo" );
|
||||
}
|
||||
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs( server, args );
|
||||
if ( !rimCase ) return true;
|
||||
|
||||
RiaDefines::PorosityModelType porosityModel = RiaDefines::MATRIX_MODEL;
|
||||
|
||||
if (args.size() > 2)
|
||||
if ( args.size() > 2 )
|
||||
{
|
||||
QString prorosityModelString = args[2];
|
||||
if (prorosityModelString.toUpper() == "FRACTURE")
|
||||
if ( prorosityModelString.toUpper() == "FRACTURE" )
|
||||
{
|
||||
porosityModel = RiaDefines::FRACTURE_MODEL;
|
||||
}
|
||||
@@ -119,23 +120,24 @@ public:
|
||||
// Write data back to octave: columnCount, bytesPrTimestep, GridNr I J K ParentGridNr PI PJ PK CoarseBoxIdx
|
||||
|
||||
std::array<std::vector<qint32>, 9> activeCellInfo;
|
||||
if (!(rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid()) )
|
||||
if ( !( rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid() ) )
|
||||
{
|
||||
// No data available
|
||||
socketStream << (quint64)0 << (quint64)0 ;
|
||||
socketStream << (quint64)0 << (quint64)0;
|
||||
return true;
|
||||
}
|
||||
|
||||
calculateMatrixModelActiveCellInfo(rimCase, porosityModel,
|
||||
activeCellInfo[0],
|
||||
activeCellInfo[1],
|
||||
activeCellInfo[2],
|
||||
activeCellInfo[3],
|
||||
activeCellInfo[4],
|
||||
activeCellInfo[5],
|
||||
activeCellInfo[6],
|
||||
activeCellInfo[7],
|
||||
activeCellInfo[8]);
|
||||
calculateMatrixModelActiveCellInfo( rimCase,
|
||||
porosityModel,
|
||||
activeCellInfo[0],
|
||||
activeCellInfo[1],
|
||||
activeCellInfo[2],
|
||||
activeCellInfo[3],
|
||||
activeCellInfo[4],
|
||||
activeCellInfo[5],
|
||||
activeCellInfo[6],
|
||||
activeCellInfo[7],
|
||||
activeCellInfo[8] );
|
||||
|
||||
// First write column count
|
||||
quint64 columnCount = (quint64)9;
|
||||
@@ -143,18 +145,31 @@ public:
|
||||
|
||||
// then the byte-size of the size of one column
|
||||
size_t timestepResultCount = activeCellInfo[0].size();
|
||||
quint64 timestepByteCount = (quint64)(timestepResultCount*sizeof(qint32));
|
||||
quint64 timestepByteCount = ( quint64 )( timestepResultCount * sizeof( qint32 ) );
|
||||
socketStream << timestepByteCount;
|
||||
|
||||
for (size_t tIdx = 0; tIdx < columnCount; ++tIdx)
|
||||
for ( size_t tIdx = 0; tIdx < columnCount; ++tIdx )
|
||||
{
|
||||
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)activeCellInfo[tIdx].data(), timestepByteCount);
|
||||
RiaSocketTools::writeBlockData( server,
|
||||
server->currentClient(),
|
||||
(const char*)activeCellInfo[tIdx].data(),
|
||||
timestepByteCount );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void calculateMatrixModelActiveCellInfo(RimEclipseCase* reservoirCase, RiaDefines::PorosityModelType porosityModel, 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, std::vector<qint32>& globalCoarseningBoxIdx)
|
||||
static void calculateMatrixModelActiveCellInfo( RimEclipseCase* reservoirCase,
|
||||
RiaDefines::PorosityModelType porosityModel,
|
||||
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,
|
||||
std::vector<qint32>& globalCoarseningBoxIdx )
|
||||
{
|
||||
gridNumber.clear();
|
||||
cellI.clear();
|
||||
@@ -166,121 +181,122 @@ public:
|
||||
hostCellK.clear();
|
||||
globalCoarseningBoxIdx.clear();
|
||||
|
||||
if (!reservoirCase || !reservoirCase->eclipseCaseData() || !reservoirCase->eclipseCaseData()->mainGrid())
|
||||
if ( !reservoirCase || !reservoirCase->eclipseCaseData() || !reservoirCase->eclipseCaseData()->mainGrid() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RigActiveCellInfo* actCellInfo = reservoirCase->eclipseCaseData()->activeCellInfo(porosityModel);
|
||||
size_t numMatrixModelActiveCells = actCellInfo->reservoirActiveCellCount();
|
||||
RigActiveCellInfo* actCellInfo = reservoirCase->eclipseCaseData()->activeCellInfo( porosityModel );
|
||||
size_t numMatrixModelActiveCells = actCellInfo->reservoirActiveCellCount();
|
||||
|
||||
gridNumber.reserve(numMatrixModelActiveCells);
|
||||
cellI.reserve(numMatrixModelActiveCells);
|
||||
cellJ.reserve(numMatrixModelActiveCells);
|
||||
cellK.reserve(numMatrixModelActiveCells);
|
||||
parentGridNumber.reserve(numMatrixModelActiveCells);
|
||||
hostCellI.reserve(numMatrixModelActiveCells);
|
||||
hostCellJ.reserve(numMatrixModelActiveCells);
|
||||
hostCellK.reserve(numMatrixModelActiveCells);
|
||||
globalCoarseningBoxIdx.reserve(numMatrixModelActiveCells);
|
||||
gridNumber.reserve( numMatrixModelActiveCells );
|
||||
cellI.reserve( numMatrixModelActiveCells );
|
||||
cellJ.reserve( numMatrixModelActiveCells );
|
||||
cellK.reserve( numMatrixModelActiveCells );
|
||||
parentGridNumber.reserve( numMatrixModelActiveCells );
|
||||
hostCellI.reserve( numMatrixModelActiveCells );
|
||||
hostCellJ.reserve( numMatrixModelActiveCells );
|
||||
hostCellK.reserve( numMatrixModelActiveCells );
|
||||
globalCoarseningBoxIdx.reserve( numMatrixModelActiveCells );
|
||||
|
||||
const std::vector<RigCell>& reservoirCells = reservoirCase->eclipseCaseData()->mainGrid()->globalCellArray();
|
||||
|
||||
|
||||
std::vector<size_t> globalCoarseningBoxIndexStart;
|
||||
{
|
||||
size_t globalCoarseningBoxCount = 0;
|
||||
|
||||
for (size_t gridIdx = 0; gridIdx < reservoirCase->eclipseCaseData()->gridCount(); gridIdx++)
|
||||
for ( size_t gridIdx = 0; gridIdx < reservoirCase->eclipseCaseData()->gridCount(); gridIdx++ )
|
||||
{
|
||||
globalCoarseningBoxIndexStart.push_back(globalCoarseningBoxCount);
|
||||
globalCoarseningBoxIndexStart.push_back( globalCoarseningBoxCount );
|
||||
|
||||
RigGridBase* grid = reservoirCase->eclipseCaseData()->grid(gridIdx);
|
||||
RigGridBase* grid = reservoirCase->eclipseCaseData()->grid( gridIdx );
|
||||
|
||||
size_t localCoarseningBoxCount = grid->coarseningBoxCount();
|
||||
globalCoarseningBoxCount += localCoarseningBoxCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (size_t cIdx = 0; cIdx < reservoirCells.size(); ++cIdx)
|
||||
for ( size_t cIdx = 0; cIdx < reservoirCells.size(); ++cIdx )
|
||||
{
|
||||
if (actCellInfo->isActive(cIdx))
|
||||
if ( actCellInfo->isActive( cIdx ) )
|
||||
{
|
||||
RigGridBase* grid = reservoirCells[cIdx].hostGrid();
|
||||
CVF_ASSERT(grid != nullptr);
|
||||
CVF_ASSERT( grid != nullptr );
|
||||
size_t cellIndex = reservoirCells[cIdx].gridLocalCellIndex();
|
||||
|
||||
size_t i, j, k;
|
||||
grid->ijkFromCellIndex(cellIndex, &i, &j, &k);
|
||||
grid->ijkFromCellIndex( cellIndex, &i, &j, &k );
|
||||
|
||||
size_t pi, pj, pk;
|
||||
size_t pi, pj, pk;
|
||||
RigGridBase* parentGrid = nullptr;
|
||||
|
||||
if (grid->isMainGrid())
|
||||
if ( grid->isMainGrid() )
|
||||
{
|
||||
pi = i;
|
||||
pj = j;
|
||||
pk = k;
|
||||
pi = i;
|
||||
pj = j;
|
||||
pk = k;
|
||||
parentGrid = grid;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t parentCellIdx = reservoirCells[cIdx].parentCellIndex();
|
||||
parentGrid = (static_cast<RigLocalGrid*>(grid))->parentGrid();
|
||||
CVF_ASSERT(parentGrid != nullptr);
|
||||
parentGrid->ijkFromCellIndex(parentCellIdx, &pi, &pj, &pk);
|
||||
parentGrid = ( static_cast<RigLocalGrid*>( grid ) )->parentGrid();
|
||||
CVF_ASSERT( parentGrid != nullptr );
|
||||
parentGrid->ijkFromCellIndex( parentCellIdx, &pi, &pj, &pk );
|
||||
}
|
||||
|
||||
gridNumber.push_back(static_cast<qint32>(grid->gridIndex()));
|
||||
cellI.push_back(static_cast<qint32>(i + 1)); // NB: 1-based index in Octave
|
||||
cellJ.push_back(static_cast<qint32>(j + 1)); // NB: 1-based index in Octave
|
||||
cellK.push_back(static_cast<qint32>(k + 1)); // NB: 1-based index in Octave
|
||||
gridNumber.push_back( static_cast<qint32>( grid->gridIndex() ) );
|
||||
cellI.push_back( static_cast<qint32>( i + 1 ) ); // NB: 1-based index in Octave
|
||||
cellJ.push_back( static_cast<qint32>( j + 1 ) ); // NB: 1-based index in Octave
|
||||
cellK.push_back( static_cast<qint32>( k + 1 ) ); // NB: 1-based index in Octave
|
||||
|
||||
parentGridNumber.push_back(static_cast<qint32>(parentGrid->gridIndex()));
|
||||
hostCellI.push_back(static_cast<qint32>(pi + 1)); // NB: 1-based index in Octave
|
||||
hostCellJ.push_back(static_cast<qint32>(pj + 1)); // NB: 1-based index in Octave
|
||||
hostCellK.push_back(static_cast<qint32>(pk + 1)); // NB: 1-based index in Octave
|
||||
parentGridNumber.push_back( static_cast<qint32>( parentGrid->gridIndex() ) );
|
||||
hostCellI.push_back( static_cast<qint32>( pi + 1 ) ); // NB: 1-based index in Octave
|
||||
hostCellJ.push_back( static_cast<qint32>( pj + 1 ) ); // NB: 1-based index in Octave
|
||||
hostCellK.push_back( static_cast<qint32>( pk + 1 ) ); // NB: 1-based index in Octave
|
||||
|
||||
size_t coarseningIdx = reservoirCells[cIdx].coarseningBoxIndex();
|
||||
if (coarseningIdx != cvf::UNDEFINED_SIZE_T)
|
||||
if ( coarseningIdx != cvf::UNDEFINED_SIZE_T )
|
||||
{
|
||||
size_t globalCoarseningIdx = globalCoarseningBoxIndexStart[grid->gridIndex()] + coarseningIdx;
|
||||
|
||||
globalCoarseningBoxIdx.push_back(static_cast<qint32>(globalCoarseningIdx + 1)); // NB: 1-based index in Octave
|
||||
globalCoarseningBoxIdx.push_back(
|
||||
static_cast<qint32>( globalCoarseningIdx + 1 ) ); // NB: 1-based index in Octave
|
||||
}
|
||||
else
|
||||
{
|
||||
globalCoarseningBoxIdx.push_back(-1);
|
||||
globalCoarseningBoxIdx.push_back( -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetActiveCellInfo_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetActiveCellInfo>(RiaGetActiveCellInfo::commandName());
|
||||
|
||||
static bool RiaGetActiveCellInfo_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetActiveCellInfo>(
|
||||
RiaGetActiveCellInfo::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetCoarseningInfo : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetCoarseningInfo"); }
|
||||
static QString commandName()
|
||||
{
|
||||
return QString( "GetCoarseningInfo" );
|
||||
}
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
|
||||
if (args.size() == 2)
|
||||
if ( args.size() == 2 )
|
||||
{
|
||||
argCaseGroupId = args[1].toInt();
|
||||
}
|
||||
|
||||
RimEclipseCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
if (!rimCase || !rimCase->eclipseCaseData() || !rimCase->eclipseCaseData()->mainGrid())
|
||||
RimEclipseCase* rimCase = server->findReservoir( argCaseGroupId );
|
||||
if ( !rimCase || !rimCase->eclipseCaseData() || !rimCase->eclipseCaseData()->mainGrid() )
|
||||
{
|
||||
quint64 byteCount = 0;
|
||||
|
||||
@@ -291,38 +307,38 @@ public:
|
||||
|
||||
// Write data back to octave: I1, I2, J1, J2, K1, K2 for all coarsening boxes
|
||||
|
||||
if (rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid())
|
||||
if ( rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid() )
|
||||
{
|
||||
size_t globalCoarseningBoxCount = 0;
|
||||
|
||||
for (size_t gridIdx = 0; gridIdx < rimCase->eclipseCaseData()->gridCount(); gridIdx++)
|
||||
for ( size_t gridIdx = 0; gridIdx < rimCase->eclipseCaseData()->gridCount(); gridIdx++ )
|
||||
{
|
||||
RigGridBase* grid = rimCase->eclipseCaseData()->grid(gridIdx);
|
||||
RigGridBase* grid = rimCase->eclipseCaseData()->grid( gridIdx );
|
||||
|
||||
size_t localCoarseningBoxCount = grid->coarseningBoxCount();
|
||||
globalCoarseningBoxCount += localCoarseningBoxCount;
|
||||
}
|
||||
|
||||
quint64 byteCount = globalCoarseningBoxCount * 6 * sizeof(qint32);
|
||||
quint64 byteCount = globalCoarseningBoxCount * 6 * sizeof( qint32 );
|
||||
socketStream << byteCount;
|
||||
|
||||
for (size_t gridIdx = 0; gridIdx < rimCase->eclipseCaseData()->gridCount(); gridIdx++)
|
||||
for ( size_t gridIdx = 0; gridIdx < rimCase->eclipseCaseData()->gridCount(); gridIdx++ )
|
||||
{
|
||||
RigGridBase* grid = rimCase->eclipseCaseData()->grid(gridIdx);
|
||||
RigGridBase* grid = rimCase->eclipseCaseData()->grid( gridIdx );
|
||||
|
||||
size_t localCoarseningBoxCount = grid->coarseningBoxCount();
|
||||
for (size_t boxIdx = 0; boxIdx < localCoarseningBoxCount; boxIdx++)
|
||||
for ( size_t boxIdx = 0; boxIdx < localCoarseningBoxCount; boxIdx++ )
|
||||
{
|
||||
size_t i1, i2, j1, j2, k1, k2;
|
||||
grid->coarseningBox(boxIdx, &i1, &i2, &j1, &j2, &k1, &k2);
|
||||
grid->coarseningBox( boxIdx, &i1, &i2, &j1, &j2, &k1, &k2 );
|
||||
|
||||
// Write 1-based coordinates for coarsening box
|
||||
socketStream << static_cast<qint32>(i1 + 1);
|
||||
socketStream << static_cast<qint32>(i2 + 1);
|
||||
socketStream << static_cast<qint32>(j1 + 1);
|
||||
socketStream << static_cast<qint32>(j2 + 1);
|
||||
socketStream << static_cast<qint32>(k1 + 1);
|
||||
socketStream << static_cast<qint32>(k2 + 1);
|
||||
socketStream << static_cast<qint32>( i1 + 1 );
|
||||
socketStream << static_cast<qint32>( i2 + 1 );
|
||||
socketStream << static_cast<qint32>( j1 + 1 );
|
||||
socketStream << static_cast<qint32>( j2 + 1 );
|
||||
socketStream << static_cast<qint32>( k1 + 1 );
|
||||
socketStream << static_cast<qint32>( k2 + 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,28 +347,31 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetCoarseningInfo_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCoarseningInfo>(RiaGetCoarseningInfo::commandName());
|
||||
|
||||
static bool RiaGetCoarseningInfo_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCoarseningInfo>(
|
||||
RiaGetCoarseningInfo::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetGridDimensions : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetGridDimensions"); }
|
||||
static QString commandName()
|
||||
{
|
||||
return QString( "GetGridDimensions" );
|
||||
}
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
|
||||
if (args.size() == 2)
|
||||
if ( args.size() == 2 )
|
||||
{
|
||||
argCaseGroupId = args[1].toInt();
|
||||
}
|
||||
|
||||
RimEclipseCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
if (!rimCase || !rimCase->eclipseCaseData() || !rimCase->eclipseCaseData()->mainGrid())
|
||||
RimEclipseCase* rimCase = server->findReservoir( argCaseGroupId );
|
||||
if ( !rimCase || !rimCase->eclipseCaseData() || !rimCase->eclipseCaseData()->mainGrid() )
|
||||
{
|
||||
quint64 byteCount = 0;
|
||||
|
||||
@@ -363,16 +382,15 @@ public:
|
||||
|
||||
// Write data back to octave: I, J, K dimensions
|
||||
|
||||
|
||||
if (rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid())
|
||||
if ( rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid() )
|
||||
{
|
||||
std::vector<RigGridBase*> grids;
|
||||
rimCase->eclipseCaseData()->allGrids(&grids);
|
||||
rimCase->eclipseCaseData()->allGrids( &grids );
|
||||
|
||||
quint64 byteCount = grids.size() * 3 * sizeof(quint64);
|
||||
quint64 byteCount = grids.size() * 3 * sizeof( quint64 );
|
||||
socketStream << byteCount;
|
||||
|
||||
for (size_t i = 0; i < grids.size(); i++)
|
||||
for ( size_t i = 0; i < grids.size(); i++ )
|
||||
{
|
||||
size_t iCount = 0;
|
||||
size_t jCount = 0;
|
||||
@@ -390,50 +408,52 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetGridDimensions_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetGridDimensions>(RiaGetGridDimensions::commandName());
|
||||
|
||||
|
||||
static bool RiaGetGridDimensions_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetGridDimensions>(
|
||||
RiaGetGridDimensions::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetTimeStepDates : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetTimeStepDates"); }
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
return QString( "GetTimeStepDates" );
|
||||
}
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
|
||||
if (args.size() == 2)
|
||||
if ( args.size() == 2 )
|
||||
{
|
||||
argCaseGroupId = args[1].toInt();
|
||||
}
|
||||
|
||||
RimEclipseCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
RimEclipseCase* rimCase = server->findReservoir( argCaseGroupId );
|
||||
|
||||
bool canFetchData = true;
|
||||
|
||||
if (!rimCase || !rimCase->eclipseCaseData())
|
||||
if ( !rimCase || !rimCase->eclipseCaseData() )
|
||||
{
|
||||
canFetchData = false;
|
||||
}
|
||||
|
||||
RigEclipseResultAddress addrToMaxTimeStepCountResult;
|
||||
if (rimCase && rimCase->eclipseCaseData())
|
||||
if ( rimCase && rimCase->eclipseCaseData() )
|
||||
{
|
||||
rimCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->maxTimeStepCount(&addrToMaxTimeStepCountResult);
|
||||
if ( !addrToMaxTimeStepCountResult.isValid())
|
||||
rimCase->eclipseCaseData()->results( RiaDefines::MATRIX_MODEL )->maxTimeStepCount( &addrToMaxTimeStepCountResult );
|
||||
if ( !addrToMaxTimeStepCountResult.isValid() )
|
||||
{
|
||||
canFetchData = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Did not find any result to fetch data from, return zero data found
|
||||
if (!canFetchData)
|
||||
if ( !canFetchData )
|
||||
{
|
||||
quint64 timeStepCount = 0;
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
quint64 byteCount = sizeof( quint64 );
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << timeStepCount;
|
||||
@@ -441,15 +461,18 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<QDateTime> timeStepDates = rimCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->timeStepDates(RigEclipseResultAddress(addrToMaxTimeStepCountResult));
|
||||
std::vector<QDateTime> timeStepDates = rimCase->eclipseCaseData()
|
||||
->results( RiaDefines::MATRIX_MODEL )
|
||||
->timeStepDates(
|
||||
RigEclipseResultAddress( addrToMaxTimeStepCountResult ) );
|
||||
|
||||
quint64 timeStepCount = timeStepDates.size();
|
||||
quint64 byteCount = sizeof(quint64) + 6 * timeStepCount * sizeof(qint32);
|
||||
quint64 byteCount = sizeof( quint64 ) + 6 * timeStepCount * sizeof( qint32 );
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << timeStepCount;
|
||||
|
||||
for (size_t i = 0; i < timeStepCount; i++)
|
||||
for ( size_t i = 0; i < timeStepCount; i++ )
|
||||
{
|
||||
qint32 intValue = 0;
|
||||
|
||||
@@ -474,53 +497,54 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static bool RiaGetTimeStepDates_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetTimeStepDates>(RiaGetTimeStepDates::commandName());
|
||||
|
||||
|
||||
static bool RiaGetTimeStepDates_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetTimeStepDates>(
|
||||
RiaGetTimeStepDates::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetTimeStepDays : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetTimeStepDays"); }
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
return QString( "GetTimeStepDays" );
|
||||
}
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
|
||||
if (args.size() == 2)
|
||||
if ( args.size() == 2 )
|
||||
{
|
||||
argCaseGroupId = args[1].toInt();
|
||||
}
|
||||
|
||||
RimEclipseCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
RimEclipseCase* rimCase = server->findReservoir( argCaseGroupId );
|
||||
|
||||
bool canFetchData = true;
|
||||
|
||||
if (!rimCase || !rimCase->eclipseCaseData())
|
||||
if ( !rimCase || !rimCase->eclipseCaseData() )
|
||||
{
|
||||
canFetchData = false;
|
||||
}
|
||||
|
||||
RigEclipseResultAddress addrToMaxTimeStepCountResult;
|
||||
if (rimCase && rimCase->eclipseCaseData())
|
||||
if ( rimCase && rimCase->eclipseCaseData() )
|
||||
{
|
||||
rimCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->maxTimeStepCount(&addrToMaxTimeStepCountResult);
|
||||
if (!addrToMaxTimeStepCountResult.isValid() )
|
||||
rimCase->eclipseCaseData()->results( RiaDefines::MATRIX_MODEL )->maxTimeStepCount( &addrToMaxTimeStepCountResult );
|
||||
if ( !addrToMaxTimeStepCountResult.isValid() )
|
||||
{
|
||||
canFetchData = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Did not find any result to fetch data from, return zero data found
|
||||
if (!canFetchData)
|
||||
if ( !canFetchData )
|
||||
{
|
||||
quint64 timeStepCount = 0;
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
quint64 byteCount = sizeof( quint64 );
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << timeStepCount;
|
||||
@@ -528,116 +552,131 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<double> daysSinceSimulationStart = rimCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->daysSinceSimulationStart(addrToMaxTimeStepCountResult);
|
||||
std::vector<double> daysSinceSimulationStart = rimCase->eclipseCaseData()
|
||||
->results( RiaDefines::MATRIX_MODEL )
|
||||
->daysSinceSimulationStart( addrToMaxTimeStepCountResult );
|
||||
|
||||
quint64 timeStepCount = daysSinceSimulationStart.size();
|
||||
quint64 byteCount = sizeof(quint64) + timeStepCount * sizeof(qint32);
|
||||
quint64 byteCount = sizeof( quint64 ) + timeStepCount * sizeof( qint32 );
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << timeStepCount;
|
||||
|
||||
for (double day : daysSinceSimulationStart)
|
||||
for ( double day : daysSinceSimulationStart )
|
||||
{
|
||||
socketStream << day;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static bool RiaGetTimeStepDays_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetTimeStepDays>(RiaGetTimeStepDays::commandName());
|
||||
static bool RiaGetTimeStepDays_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetTimeStepDays>(
|
||||
RiaGetTimeStepDays::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetSelectedCells: public RiaSocketCommand
|
||||
class RiaGetSelectedCells : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetSelectedCells"); }
|
||||
static QString commandName()
|
||||
{
|
||||
return QString( "GetSelectedCells" );
|
||||
}
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
// findCaseFromArgs only returns RimEclipseCase, so geomech cases are not supported because of this.
|
||||
// The rest of the function supports geomech cases, so using a findCaseFromArgs that supports geomech
|
||||
// cases is the only change needed to add geomech support.
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
if (!rimCase) return true;
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs( server, args );
|
||||
if ( !rimCase ) return true;
|
||||
|
||||
// Write data back to octave: column count, bytes per column, caseId, gridNumber, cellI, cellJ, cellK
|
||||
|
||||
std::array<std::vector<qint32>, 5> selectedCellInfo;
|
||||
getSelectedCells(rimCase,
|
||||
selectedCellInfo[0],
|
||||
selectedCellInfo[1],
|
||||
selectedCellInfo[2],
|
||||
selectedCellInfo[3],
|
||||
selectedCellInfo[4]);
|
||||
getSelectedCells( rimCase,
|
||||
selectedCellInfo[0],
|
||||
selectedCellInfo[1],
|
||||
selectedCellInfo[2],
|
||||
selectedCellInfo[3],
|
||||
selectedCellInfo[4] );
|
||||
|
||||
// First write column count
|
||||
quint64 columnCount = 5;
|
||||
socketStream << columnCount;
|
||||
|
||||
// then the byte-size of the size of one column
|
||||
quint64 columnByteCount = (quint64)(selectedCellInfo[0].size()*sizeof(qint32));
|
||||
quint64 columnByteCount = ( quint64 )( selectedCellInfo[0].size() * sizeof( qint32 ) );
|
||||
socketStream << columnByteCount;
|
||||
|
||||
// Write back table data
|
||||
for (size_t tIdx = 0; tIdx < columnCount; ++tIdx)
|
||||
for ( size_t tIdx = 0; tIdx < columnCount; ++tIdx )
|
||||
{
|
||||
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)selectedCellInfo[tIdx].data(), columnByteCount);
|
||||
RiaSocketTools::writeBlockData( server,
|
||||
server->currentClient(),
|
||||
(const char*)selectedCellInfo[tIdx].data(),
|
||||
columnByteCount );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void getSelectedCells(const RimCase* reservoirCase,
|
||||
std::vector<qint32>& caseNumber,
|
||||
std::vector<qint32>& gridNumber,
|
||||
std::vector<qint32>& cellI,
|
||||
std::vector<qint32>& cellJ,
|
||||
std::vector<qint32>& cellK)
|
||||
static void getSelectedCells( const RimCase* reservoirCase,
|
||||
std::vector<qint32>& caseNumber,
|
||||
std::vector<qint32>& gridNumber,
|
||||
std::vector<qint32>& cellI,
|
||||
std::vector<qint32>& cellJ,
|
||||
std::vector<qint32>& cellK )
|
||||
{
|
||||
std::vector<RiuSelectionItem*> items;
|
||||
Riu3dSelectionManager::instance()->selectedItems(items);
|
||||
Riu3dSelectionManager::instance()->selectedItems( items );
|
||||
|
||||
for (const RiuSelectionItem* item : items)
|
||||
for ( const RiuSelectionItem* item : items )
|
||||
{
|
||||
size_t i, j, k;
|
||||
size_t gridIndex;
|
||||
int caseId;
|
||||
bool validIndex = true;
|
||||
if (item->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT)
|
||||
int caseId;
|
||||
bool validIndex = true;
|
||||
if ( item->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT )
|
||||
{
|
||||
const RiuEclipseSelectionItem* eclipseItem = static_cast<const RiuEclipseSelectionItem*>(item);
|
||||
const RiuEclipseSelectionItem* eclipseItem = static_cast<const RiuEclipseSelectionItem*>( item );
|
||||
|
||||
eclipseItem->m_view->eclipseCase()->eclipseCaseData()->grid(eclipseItem->m_gridIndex)->ijkFromCellIndex(eclipseItem->m_gridLocalCellIndex, &i, &j, &k);
|
||||
eclipseItem->m_view->eclipseCase()
|
||||
->eclipseCaseData()
|
||||
->grid( eclipseItem->m_gridIndex )
|
||||
->ijkFromCellIndex( eclipseItem->m_gridLocalCellIndex, &i, &j, &k );
|
||||
gridIndex = eclipseItem->m_gridIndex;
|
||||
caseId = eclipseItem->m_view->eclipseCase()->caseId;
|
||||
caseId = eclipseItem->m_view->eclipseCase()->caseId;
|
||||
}
|
||||
else if (item->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT)
|
||||
else if ( item->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT )
|
||||
{
|
||||
const RiuGeoMechSelectionItem* geomechItem = static_cast<const RiuGeoMechSelectionItem*>(item);
|
||||
validIndex = geomechItem->m_view->femParts()->part(geomechItem->m_gridIndex)->getOrCreateStructGrid()->ijkFromCellIndex(geomechItem->m_cellIndex, &i, &j, &k);
|
||||
CVF_ASSERT(validIndex);
|
||||
const RiuGeoMechSelectionItem* geomechItem = static_cast<const RiuGeoMechSelectionItem*>( item );
|
||||
validIndex = geomechItem->m_view->femParts()
|
||||
->part( geomechItem->m_gridIndex )
|
||||
->getOrCreateStructGrid()
|
||||
->ijkFromCellIndex( geomechItem->m_cellIndex, &i, &j, &k );
|
||||
CVF_ASSERT( validIndex );
|
||||
gridIndex = geomechItem->m_gridIndex;
|
||||
caseId = geomechItem->m_view->geoMechCase()->caseId;
|
||||
caseId = geomechItem->m_view->geoMechCase()->caseId;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (caseId == reservoirCase->caseId && validIndex)
|
||||
if ( caseId == reservoirCase->caseId && validIndex )
|
||||
{
|
||||
caseNumber.push_back(static_cast<int>(caseId));
|
||||
gridNumber.push_back(static_cast<int>(gridIndex));
|
||||
cellI.push_back(static_cast<int>(i + 1));
|
||||
cellJ.push_back(static_cast<int>(j + 1));
|
||||
cellK.push_back(static_cast<int>(k + 1));
|
||||
caseNumber.push_back( static_cast<int>( caseId ) );
|
||||
gridNumber.push_back( static_cast<int>( gridIndex ) );
|
||||
cellI.push_back( static_cast<int>( i + 1 ) );
|
||||
cellJ.push_back( static_cast<int>( j + 1 ) );
|
||||
cellK.push_back( static_cast<int>( k + 1 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetSelectedCells_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetSelectedCells>(RiaGetSelectedCells::commandName());
|
||||
static bool RiaGetSelectedCells_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetSelectedCells>(
|
||||
RiaGetSelectedCells::commandName() );
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron AS
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -45,7 +45,7 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Convert internal ResInsight representation of cells with negative depth to positive depth.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
static inline void convertVec3dToPositiveDepth(cvf::Vec3d* vec)
|
||||
static inline void convertVec3dToPositiveDepth( cvf::Vec3d* vec )
|
||||
{
|
||||
double& z = vec->z();
|
||||
z *= -1;
|
||||
@@ -54,9 +54,9 @@ static inline void convertVec3dToPositiveDepth(cvf::Vec3d* vec)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Retrieve a cell corner where the depth is represented as negative converted to positive depth.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
static inline double getCellCornerWithPositiveDepth(const cvf::Vec3d *cornerVerts, size_t cornerIndexMapping, int coordIdx)
|
||||
static inline double getCellCornerWithPositiveDepth( const cvf::Vec3d* cornerVerts, size_t cornerIndexMapping, int coordIdx )
|
||||
{
|
||||
if (coordIdx == 2)
|
||||
if ( coordIdx == 2 )
|
||||
{
|
||||
// Z-value aka depth
|
||||
return -1 * cornerVerts[cornerIndexMapping][coordIdx];
|
||||
@@ -73,21 +73,24 @@ static inline double getCellCornerWithPositiveDepth(const cvf::Vec3d *cornerVert
|
||||
class RiaGetCellCenters : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetCellCenters"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
size_t argGridIndex = args[2].toUInt();
|
||||
return QString( "GetCellCenters" );
|
||||
}
|
||||
|
||||
if (!rimCase || !rimCase->eclipseCaseData() || (argGridIndex >= rimCase->eclipseCaseData()->gridCount()) )
|
||||
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);
|
||||
RigGridBase* rigGrid = rimCase->eclipseCaseData()->grid( argGridIndex );
|
||||
|
||||
quint64 cellCount = (quint64)rigGrid->cellCount();
|
||||
quint64 cellCountI = (quint64)rigGrid->cellCountI();
|
||||
@@ -99,8 +102,8 @@ public:
|
||||
socketStream << cellCountJ;
|
||||
socketStream << cellCountK;
|
||||
|
||||
size_t doubleValueCount = cellCount * 3;
|
||||
quint64 byteCount = doubleValueCount * sizeof(double);
|
||||
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
|
||||
@@ -115,40 +118,43 @@ public:
|
||||
// dv(2) = cellCountK;
|
||||
// dv(3) = 3;
|
||||
|
||||
size_t blockByteCount = cellCount * sizeof(double);
|
||||
std::vector<double> doubleValues(blockByteCount);
|
||||
size_t blockByteCount = cellCount * sizeof( double );
|
||||
std::vector<double> doubleValues( blockByteCount );
|
||||
|
||||
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
|
||||
for ( int coordIdx = 0; coordIdx < 3; coordIdx++ )
|
||||
{
|
||||
quint64 valueIndex = 0;
|
||||
|
||||
for (size_t k = 0; k < cellCountK; k++)
|
||||
for ( size_t k = 0; k < cellCountK; k++ )
|
||||
{
|
||||
for (size_t j = 0; j < cellCountJ; j++)
|
||||
for ( size_t j = 0; j < cellCountJ; j++ )
|
||||
{
|
||||
for (size_t i = 0; i < cellCountI; i++)
|
||||
for ( size_t i = 0; i < cellCountI; i++ )
|
||||
{
|
||||
size_t gridLocalCellIndex = rigGrid->cellIndexFromIJK(i, j, k);
|
||||
cvf::Vec3d center = rigGrid->cell(gridLocalCellIndex).center();
|
||||
size_t gridLocalCellIndex = rigGrid->cellIndexFromIJK( i, j, k );
|
||||
cvf::Vec3d center = rigGrid->cell( gridLocalCellIndex ).center();
|
||||
|
||||
convertVec3dToPositiveDepth(¢er);
|
||||
convertVec3dToPositiveDepth( ¢er );
|
||||
|
||||
doubleValues[valueIndex++] = center[coordIdx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CVF_ASSERT(valueIndex == cellCount);
|
||||
CVF_ASSERT( valueIndex == cellCount );
|
||||
|
||||
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)doubleValues.data(), blockByteCount);
|
||||
RiaSocketTools::writeBlockData( server,
|
||||
server->currentClient(),
|
||||
(const char*)doubleValues.data(),
|
||||
blockByteCount );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetCellCenters_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCellCenters>(RiaGetCellCenters::commandName());
|
||||
|
||||
static bool RiaGetCellCenters_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCellCenters>(
|
||||
RiaGetCellCenters::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -156,39 +162,41 @@ static bool RiaGetCellCenters_init = RiaSocketCommandFactory::instance()->regist
|
||||
class RiaGetActiveCellCenters : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetActiveCellCenters"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
return QString( "GetActiveCellCenters" );
|
||||
}
|
||||
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs( server, args );
|
||||
|
||||
QString porosityModelName;
|
||||
porosityModelName = args[2];
|
||||
|
||||
RiaDefines::PorosityModelType porosityModelEnum = RiaDefines::MATRIX_MODEL;
|
||||
if (porosityModelName.toUpper() == "FRACTURE")
|
||||
if ( porosityModelName.toUpper() == "FRACTURE" )
|
||||
{
|
||||
porosityModelEnum = RiaDefines::FRACTURE_MODEL;
|
||||
}
|
||||
|
||||
if (!rimCase || !rimCase->eclipseCaseData())
|
||||
if ( !rimCase || !rimCase->eclipseCaseData() )
|
||||
{
|
||||
// No data available
|
||||
socketStream << (quint64)0 << (quint64)0 ;
|
||||
socketStream << (quint64)0 << (quint64)0;
|
||||
return true;
|
||||
}
|
||||
|
||||
RigActiveCellInfo* actCellInfo = rimCase->eclipseCaseData()->activeCellInfo(porosityModelEnum);
|
||||
RigMainGrid* mainGrid = rimCase->eclipseCaseData()->mainGrid();
|
||||
RigActiveCellInfo* actCellInfo = rimCase->eclipseCaseData()->activeCellInfo( porosityModelEnum );
|
||||
RigMainGrid* mainGrid = rimCase->eclipseCaseData()->mainGrid();
|
||||
|
||||
size_t activeCellCount = actCellInfo->reservoirActiveCellCount();
|
||||
size_t activeCellCount = actCellInfo->reservoirActiveCellCount();
|
||||
size_t doubleValueCount = activeCellCount * 3;
|
||||
|
||||
socketStream << (quint64)activeCellCount;
|
||||
quint64 byteCount = doubleValueCount * sizeof(double);
|
||||
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
|
||||
//
|
||||
@@ -199,38 +207,41 @@ public:
|
||||
// dv(0) = coordCount;
|
||||
// dv(1) = 3;
|
||||
|
||||
size_t blockByteCount = activeCellCount * sizeof(double);
|
||||
std::vector<double> doubleValues(blockByteCount);
|
||||
size_t blockByteCount = activeCellCount * sizeof( double );
|
||||
std::vector<double> doubleValues( blockByteCount );
|
||||
|
||||
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
|
||||
for ( int coordIdx = 0; coordIdx < 3; coordIdx++ )
|
||||
{
|
||||
quint64 valueIndex = 0;
|
||||
|
||||
for (size_t reservoirCellIndex = 0; reservoirCellIndex < mainGrid->globalCellArray().size(); reservoirCellIndex++)
|
||||
for ( size_t reservoirCellIndex = 0; reservoirCellIndex < mainGrid->globalCellArray().size();
|
||||
reservoirCellIndex++ )
|
||||
{
|
||||
if (!actCellInfo->isActive(reservoirCellIndex)) continue;
|
||||
if ( !actCellInfo->isActive( reservoirCellIndex ) ) continue;
|
||||
|
||||
cvf::Vec3d center = mainGrid->globalCellArray()[reservoirCellIndex].center();
|
||||
|
||||
convertVec3dToPositiveDepth(¢er);
|
||||
convertVec3dToPositiveDepth( ¢er );
|
||||
|
||||
doubleValues[valueIndex++] = center[coordIdx];
|
||||
}
|
||||
|
||||
CVF_ASSERT(valueIndex == activeCellCount);
|
||||
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)doubleValues.data(), blockByteCount);
|
||||
CVF_ASSERT( valueIndex == activeCellCount );
|
||||
RiaSocketTools::writeBlockData( server,
|
||||
server->currentClient(),
|
||||
(const char*)doubleValues.data(),
|
||||
blockByteCount );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static bool RiaGetActiveCellCenters_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetActiveCellCenters>(RiaGetActiveCellCenters::commandName());
|
||||
static bool RiaGetActiveCellCenters_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetActiveCellCenters>(
|
||||
RiaGetActiveCellCenters::commandName() );
|
||||
|
||||
|
||||
// NB: Match this mapping with the mapping in RifReaderEclipseOutput.cpp
|
||||
static const size_t cellCornerMappingEclipse[8] = { 0, 1, 3, 2, 4, 5, 7, 6 };
|
||||
// NB: Match this mapping with the mapping in RifReaderEclipseOutput.cpp
|
||||
static const size_t cellCornerMappingEclipse[8] = {0, 1, 3, 2, 4, 5, 7, 6};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -238,29 +249,32 @@ static const size_t cellCornerMappingEclipse[8] = { 0, 1, 3, 2, 4, 5, 7, 6 };
|
||||
class RiaGetCellCorners : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetCellCorners"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
size_t argGridIndex = args[2].toUInt();
|
||||
return QString( "GetCellCorners" );
|
||||
}
|
||||
|
||||
if (!rimCase || !rimCase->eclipseCaseData() || (argGridIndex >= rimCase->eclipseCaseData()->gridCount()) )
|
||||
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);
|
||||
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();
|
||||
|
||||
size_t doubleValueCount = cellCount * 3 * 8;
|
||||
quint64 byteCount = doubleValueCount * sizeof(double);
|
||||
size_t doubleValueCount = cellCount * 3 * 8;
|
||||
quint64 byteCount = doubleValueCount * sizeof( double );
|
||||
|
||||
socketStream << cellCount;
|
||||
socketStream << cellCountI;
|
||||
@@ -281,35 +295,40 @@ public:
|
||||
// dv(3) = 8;
|
||||
// dv(4) = 3;
|
||||
|
||||
cvf::Vec3d cornerVerts[8];
|
||||
size_t blockByteCount = cellCount * sizeof(double);
|
||||
std::vector<double> doubleValues(blockByteCount);
|
||||
cvf::Vec3d cornerVerts[8];
|
||||
size_t blockByteCount = cellCount * sizeof( double );
|
||||
std::vector<double> doubleValues( blockByteCount );
|
||||
|
||||
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
|
||||
for ( int coordIdx = 0; coordIdx < 3; coordIdx++ )
|
||||
{
|
||||
for (size_t cornerIdx = 0; cornerIdx < 8; cornerIdx++)
|
||||
for ( size_t cornerIdx = 0; cornerIdx < 8; cornerIdx++ )
|
||||
{
|
||||
size_t cornerIndexMapping = cellCornerMappingEclipse[cornerIdx];
|
||||
|
||||
quint64 valueIndex = 0;
|
||||
|
||||
for (size_t k = 0; k < cellCountK; k++)
|
||||
for ( size_t k = 0; k < cellCountK; k++ )
|
||||
{
|
||||
for (size_t j = 0; j < cellCountJ; j++)
|
||||
for ( size_t j = 0; j < cellCountJ; j++ )
|
||||
{
|
||||
for (size_t i = 0; i < cellCountI; i++)
|
||||
for ( size_t i = 0; i < cellCountI; i++ )
|
||||
{
|
||||
size_t gridLocalCellIndex = rigGrid->cellIndexFromIJK(i, j, k);
|
||||
rigGrid->cellCornerVertices(gridLocalCellIndex, cornerVerts);
|
||||
size_t gridLocalCellIndex = rigGrid->cellIndexFromIJK( i, j, k );
|
||||
rigGrid->cellCornerVertices( gridLocalCellIndex, cornerVerts );
|
||||
|
||||
doubleValues[valueIndex++] = getCellCornerWithPositiveDepth(cornerVerts, cornerIndexMapping, coordIdx);
|
||||
doubleValues[valueIndex++] = getCellCornerWithPositiveDepth( cornerVerts,
|
||||
cornerIndexMapping,
|
||||
coordIdx );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CVF_ASSERT(valueIndex == cellCount);
|
||||
CVF_ASSERT( valueIndex == cellCount );
|
||||
|
||||
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)doubleValues.data(), blockByteCount);
|
||||
RiaSocketTools::writeBlockData( server,
|
||||
server->currentClient(),
|
||||
(const char*)doubleValues.data(),
|
||||
blockByteCount );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,9 +336,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetCellCorners_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCellCorners>(RiaGetCellCorners::commandName());
|
||||
|
||||
|
||||
static bool RiaGetCellCorners_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCellCorners>(
|
||||
RiaGetCellCorners::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -327,36 +345,39 @@ static bool RiaGetCellCorners_init = RiaSocketCommandFactory::instance()->regist
|
||||
class RiaGetActiveCellCorners : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetActiveCellCorners"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
return QString( "GetActiveCellCorners" );
|
||||
}
|
||||
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs( server, args );
|
||||
|
||||
QString porosityModelName;
|
||||
porosityModelName = args[2];
|
||||
|
||||
RiaDefines::PorosityModelType porosityModelEnum = RiaDefines::MATRIX_MODEL;
|
||||
if (porosityModelName.toUpper() == "FRACTURE")
|
||||
if ( porosityModelName.toUpper() == "FRACTURE" )
|
||||
{
|
||||
porosityModelEnum = RiaDefines::FRACTURE_MODEL;
|
||||
}
|
||||
|
||||
if (!rimCase || !rimCase->eclipseCaseData() )
|
||||
if ( !rimCase || !rimCase->eclipseCaseData() )
|
||||
{
|
||||
// No data available
|
||||
socketStream << (quint64)0 << (quint64)0 ;
|
||||
socketStream << (quint64)0 << (quint64)0;
|
||||
return true;
|
||||
}
|
||||
|
||||
RigActiveCellInfo* actCellInfo = rimCase->eclipseCaseData()->activeCellInfo(porosityModelEnum);
|
||||
RigMainGrid* mainGrid = rimCase->eclipseCaseData()->mainGrid();
|
||||
RigActiveCellInfo* actCellInfo = rimCase->eclipseCaseData()->activeCellInfo( porosityModelEnum );
|
||||
RigMainGrid* mainGrid = rimCase->eclipseCaseData()->mainGrid();
|
||||
|
||||
size_t activeCellCount = actCellInfo->reservoirActiveCellCount();
|
||||
size_t activeCellCount = actCellInfo->reservoirActiveCellCount();
|
||||
size_t doubleValueCount = activeCellCount * 3 * 8;
|
||||
|
||||
socketStream << (quint64)activeCellCount;
|
||||
quint64 byteCount = doubleValueCount * sizeof(double);
|
||||
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
|
||||
@@ -370,36 +391,42 @@ public:
|
||||
// dv(1) = 8;
|
||||
// dv(2) = 3;
|
||||
|
||||
cvf::Vec3d cornerVerts[8];
|
||||
size_t blockByteCount = activeCellCount * sizeof(double);
|
||||
std::vector<double> doubleValues(blockByteCount);
|
||||
cvf::Vec3d cornerVerts[8];
|
||||
size_t blockByteCount = activeCellCount * sizeof( double );
|
||||
std::vector<double> doubleValues( blockByteCount );
|
||||
|
||||
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
|
||||
for ( int coordIdx = 0; coordIdx < 3; coordIdx++ )
|
||||
{
|
||||
for (size_t cornerIdx = 0; cornerIdx < 8; cornerIdx++)
|
||||
for ( size_t cornerIdx = 0; cornerIdx < 8; cornerIdx++ )
|
||||
{
|
||||
size_t cornerIndexMapping = cellCornerMappingEclipse[cornerIdx];
|
||||
|
||||
quint64 valueIndex = 0;
|
||||
|
||||
for (size_t reservoirCellIndex = 0; reservoirCellIndex < mainGrid->globalCellArray().size(); reservoirCellIndex++)
|
||||
for ( size_t reservoirCellIndex = 0; reservoirCellIndex < mainGrid->globalCellArray().size();
|
||||
reservoirCellIndex++ )
|
||||
{
|
||||
if (!actCellInfo->isActive(reservoirCellIndex)) continue;
|
||||
if ( !actCellInfo->isActive( reservoirCellIndex ) ) continue;
|
||||
|
||||
mainGrid->cellCornerVertices(reservoirCellIndex, cornerVerts);
|
||||
mainGrid->cellCornerVertices( reservoirCellIndex, cornerVerts );
|
||||
|
||||
doubleValues[valueIndex++] = getCellCornerWithPositiveDepth(cornerVerts, cornerIndexMapping, coordIdx);
|
||||
doubleValues[valueIndex++] = getCellCornerWithPositiveDepth( cornerVerts,
|
||||
cornerIndexMapping,
|
||||
coordIdx );
|
||||
}
|
||||
|
||||
CVF_ASSERT(valueIndex == activeCellCount);
|
||||
CVF_ASSERT( valueIndex == activeCellCount );
|
||||
|
||||
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)doubleValues.data(), blockByteCount);
|
||||
RiaSocketTools::writeBlockData( server,
|
||||
server->currentClient(),
|
||||
(const char*)doubleValues.data(),
|
||||
blockByteCount );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static bool RiaGetActiveCellCorners_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetActiveCellCorners>(RiaGetActiveCellCorners::commandName());
|
||||
static bool RiaGetActiveCellCorners_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetActiveCellCorners>(
|
||||
RiaGetActiveCellCorners::commandName() );
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil ASA
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaSocketCommand.h"
|
||||
|
||||
#include "RiaSocketServer.h"
|
||||
#include "RiaSocketDataTransfer.h"
|
||||
#include "RiaSocketTools.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaSocketDataTransfer.h"
|
||||
#include "RiaSocketServer.h"
|
||||
#include "RiaSocketTools.h"
|
||||
|
||||
#include "RigActiveCellInfo.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
@@ -48,16 +48,19 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetNNCConnections: public RiaSocketCommand
|
||||
class RiaGetNNCConnections : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetNNCConnections"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
return QString( "GetNNCConnections" );
|
||||
}
|
||||
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs( server, args );
|
||||
// Write data back to octave: columnCount, GridNr I J K GridNr I J K
|
||||
if (!(rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid()))
|
||||
if ( !( rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid() ) )
|
||||
{
|
||||
// No data available
|
||||
socketStream << (quint64)0;
|
||||
@@ -70,45 +73,49 @@ public:
|
||||
|
||||
socketStream << (quint64)connectionCount;
|
||||
|
||||
for (const RigConnection& connection : mainGrid->nncData()->connections())
|
||||
for ( const RigConnection& connection : mainGrid->nncData()->connections() )
|
||||
{
|
||||
const RigCell& cell1 = mainGrid->globalCellArray()[connection.m_c1GlobIdx];
|
||||
const RigCell& cell2 = mainGrid->globalCellArray()[connection.m_c2GlobIdx];
|
||||
|
||||
sendCellInfo(socketStream, cell1);
|
||||
sendCellInfo(socketStream, cell2);
|
||||
sendCellInfo( socketStream, cell1 );
|
||||
sendCellInfo( socketStream, cell2 );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void sendCellInfo(QDataStream& socketStream, const RigCell& cell)
|
||||
static void sendCellInfo( QDataStream& socketStream, const RigCell& cell )
|
||||
{
|
||||
RigGridBase* hostGrid = cell.hostGrid();
|
||||
size_t gridLocalCellIndex = cell.gridLocalCellIndex();
|
||||
size_t i, j, k;
|
||||
hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k);
|
||||
RigGridBase* hostGrid = cell.hostGrid();
|
||||
size_t gridLocalCellIndex = cell.gridLocalCellIndex();
|
||||
size_t i, j, k;
|
||||
hostGrid->ijkFromCellIndex( gridLocalCellIndex, &i, &j, &k );
|
||||
|
||||
socketStream << (qint32)hostGrid->gridIndex();
|
||||
socketStream << (qint32)(i+1) << (qint32)(j+1) << (qint32)(k+1);
|
||||
socketStream << ( qint32 )( i + 1 ) << ( qint32 )( j + 1 ) << ( qint32 )( k + 1 );
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetNNCConnections_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetNNCConnections>(RiaGetNNCConnections::commandName());
|
||||
static bool RiaGetNNCConnections_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetNNCConnections>(
|
||||
RiaGetNNCConnections::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetDynamicNNCValues: public RiaSocketCommand
|
||||
class RiaGetDynamicNNCValues : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetDynamicNNCValues"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
return QString( "GetDynamicNNCValues" );
|
||||
}
|
||||
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs( server, args );
|
||||
// Write data back to octave: connectionCount, timeStepCount, property values
|
||||
if (!(rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid()))
|
||||
if ( !( rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid() ) )
|
||||
{
|
||||
// No data available
|
||||
socketStream << (quint64)0 << (quint64)0;
|
||||
@@ -117,27 +124,28 @@ public:
|
||||
|
||||
QString propertyName = args[2];
|
||||
|
||||
RigMainGrid* mainGrid = rimCase->eclipseCaseData()->mainGrid();
|
||||
const std::vector< std::vector<double> >* nncValues = mainGrid->nncData()->dynamicConnectionScalarResultByName(propertyName);
|
||||
RigMainGrid* mainGrid = rimCase->eclipseCaseData()->mainGrid();
|
||||
const std::vector<std::vector<double>>* nncValues = mainGrid->nncData()->dynamicConnectionScalarResultByName(
|
||||
propertyName );
|
||||
|
||||
if (nncValues == nullptr)
|
||||
if ( nncValues == nullptr )
|
||||
{
|
||||
socketStream << (quint64)0 << (quint64)0;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<size_t> requestedTimeSteps;
|
||||
if (args.size() > 3)
|
||||
if ( args.size() > 3 )
|
||||
{
|
||||
bool timeStepReadError = false;
|
||||
for (int argIdx = 3; argIdx < args.size(); ++argIdx)
|
||||
for ( int argIdx = 3; argIdx < args.size(); ++argIdx )
|
||||
{
|
||||
bool conversionOk = false;
|
||||
int tsIdx = args[argIdx].toInt(&conversionOk);
|
||||
int tsIdx = args[argIdx].toInt( &conversionOk );
|
||||
|
||||
if (conversionOk)
|
||||
if ( conversionOk )
|
||||
{
|
||||
requestedTimeSteps.push_back(tsIdx);
|
||||
requestedTimeSteps.push_back( tsIdx );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -145,63 +153,72 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (timeStepReadError)
|
||||
if ( timeStepReadError )
|
||||
{
|
||||
server->showErrorMessage(RiaSocketServer::tr("ResInsight SocketServer: riGetDynamicNNCValues : \n") + RiaSocketServer::tr("An error occurred while interpreting the requested time steps."));
|
||||
server->showErrorMessage(
|
||||
RiaSocketServer::tr( "ResInsight SocketServer: riGetDynamicNNCValues : \n" ) +
|
||||
RiaSocketServer::tr( "An error occurred while interpreting the requested time steps." ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t timeStep = 0; timeStep < nncValues->size(); ++timeStep)
|
||||
for ( size_t timeStep = 0; timeStep < nncValues->size(); ++timeStep )
|
||||
{
|
||||
requestedTimeSteps.push_back(timeStep);
|
||||
requestedTimeSteps.push_back( timeStep );
|
||||
}
|
||||
}
|
||||
|
||||
// then the connection count and time step count.
|
||||
size_t connectionCount = mainGrid->nncData()->connections().size();
|
||||
size_t timeStepCount = requestedTimeSteps.size();
|
||||
size_t timeStepCount = requestedTimeSteps.size();
|
||||
|
||||
socketStream << (quint64)connectionCount;
|
||||
socketStream << (quint64)timeStepCount;
|
||||
|
||||
for (size_t timeStep : requestedTimeSteps)
|
||||
for ( size_t timeStep : requestedTimeSteps )
|
||||
{
|
||||
const std::vector<double>& timeStepValues = nncValues->at(timeStep);
|
||||
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)timeStepValues.data(), sizeof(double) * timeStepValues.size());
|
||||
const std::vector<double>& timeStepValues = nncValues->at( timeStep );
|
||||
RiaSocketTools::writeBlockData( server,
|
||||
server->currentClient(),
|
||||
(const char*)timeStepValues.data(),
|
||||
sizeof( double ) * timeStepValues.size() );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetDynamicNNCValues_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetDynamicNNCValues>(RiaGetDynamicNNCValues::commandName());
|
||||
static bool RiaGetDynamicNNCValues_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetDynamicNNCValues>(
|
||||
RiaGetDynamicNNCValues::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetStaticNNCValues: public RiaSocketCommand
|
||||
class RiaGetStaticNNCValues : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetStaticNNCValues"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
QString propertyName = args[2];
|
||||
return QString( "GetStaticNNCValues" );
|
||||
}
|
||||
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs( server, args );
|
||||
QString propertyName = args[2];
|
||||
|
||||
// Write data back to octave: connectionCount, property values
|
||||
if (!(rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid()))
|
||||
if ( !( rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid() ) )
|
||||
{
|
||||
// No data available
|
||||
socketStream << (quint64)0;
|
||||
return true;
|
||||
}
|
||||
|
||||
RigMainGrid* mainGrid = rimCase->eclipseCaseData()->mainGrid();
|
||||
const std::vector<double>* nncValues = mainGrid->nncData()->staticConnectionScalarResultByName(propertyName);
|
||||
RigMainGrid* mainGrid = rimCase->eclipseCaseData()->mainGrid();
|
||||
const std::vector<double>* nncValues = mainGrid->nncData()->staticConnectionScalarResultByName( propertyName );
|
||||
|
||||
if (nncValues == nullptr)
|
||||
if ( nncValues == nullptr )
|
||||
{
|
||||
socketStream << (quint64)0;
|
||||
return true;
|
||||
@@ -211,27 +228,34 @@ public:
|
||||
size_t connectionCount = mainGrid->nncData()->connections().size();
|
||||
socketStream << (quint64)connectionCount;
|
||||
|
||||
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)nncValues->data(), sizeof(double) * nncValues->size());
|
||||
RiaSocketTools::writeBlockData( server,
|
||||
server->currentClient(),
|
||||
(const char*)nncValues->data(),
|
||||
sizeof( double ) * nncValues->size() );
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetStaticNNCValues_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetStaticNNCValues>(RiaGetStaticNNCValues::commandName());
|
||||
static bool RiaGetStaticNNCValues_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetStaticNNCValues>(
|
||||
RiaGetStaticNNCValues::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetNNCPropertyNames: public RiaSocketCommand
|
||||
class RiaGetNNCPropertyNames : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetNNCPropertyNames"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
return QString( "GetNNCPropertyNames" );
|
||||
}
|
||||
|
||||
if (!(rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid()))
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs( server, args );
|
||||
|
||||
if ( !( rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid() ) )
|
||||
{
|
||||
// No data available
|
||||
socketStream << (quint64)0;
|
||||
@@ -244,32 +268,32 @@ public:
|
||||
std::vector<QString> propertyNames;
|
||||
|
||||
std::vector<RigNNCData::NNCResultType> resultTypes;
|
||||
std::vector<QString> resultTypeNames;
|
||||
std::vector<QString> resultTypeNames;
|
||||
|
||||
resultTypes.push_back(RigNNCData::NNC_DYNAMIC);
|
||||
resultTypeNames.push_back("DynamicNative");
|
||||
resultTypes.push_back(RigNNCData::NNC_STATIC);
|
||||
resultTypeNames.push_back("StaticNative");
|
||||
resultTypes.push_back(RigNNCData::NNC_GENERATED);
|
||||
resultTypeNames.push_back("Generated");
|
||||
resultTypes.push_back( RigNNCData::NNC_DYNAMIC );
|
||||
resultTypeNames.push_back( "DynamicNative" );
|
||||
resultTypes.push_back( RigNNCData::NNC_STATIC );
|
||||
resultTypeNames.push_back( "StaticNative" );
|
||||
resultTypes.push_back( RigNNCData::NNC_GENERATED );
|
||||
resultTypeNames.push_back( "Generated" );
|
||||
|
||||
for (size_t rtIdx = 0; rtIdx < resultTypes.size(); ++rtIdx)
|
||||
for ( size_t rtIdx = 0; rtIdx < resultTypes.size(); ++rtIdx )
|
||||
{
|
||||
std::vector<QString> availableParameters = nncData->availableProperties(resultTypes[rtIdx]);
|
||||
std::vector<QString> availableParameters = nncData->availableProperties( resultTypes[rtIdx] );
|
||||
|
||||
for (const QString& parameter : availableParameters)
|
||||
for ( const QString& parameter : availableParameters )
|
||||
{
|
||||
propertyNames.push_back(parameter);
|
||||
propertyTypes.push_back(resultTypeNames[rtIdx]);
|
||||
propertyNames.push_back( parameter );
|
||||
propertyTypes.push_back( resultTypeNames[rtIdx] );
|
||||
}
|
||||
}
|
||||
|
||||
qint64 byteCount = 0;
|
||||
|
||||
for (size_t ptIdx = 0; ptIdx < propertyNames.size(); ++ptIdx)
|
||||
for ( size_t ptIdx = 0; ptIdx < propertyNames.size(); ++ptIdx )
|
||||
{
|
||||
byteCount += propertyNames[ptIdx].size() * sizeof(QChar);
|
||||
byteCount += propertyTypes[ptIdx].size() * sizeof(QChar);
|
||||
byteCount += propertyNames[ptIdx].size() * sizeof( QChar );
|
||||
byteCount += propertyTypes[ptIdx].size() * sizeof( QChar );
|
||||
}
|
||||
|
||||
// Byte count
|
||||
@@ -278,7 +302,7 @@ public:
|
||||
// Parameter count
|
||||
socketStream << (quint64)propertyNames.size();
|
||||
|
||||
for (size_t ptIdx = 0; ptIdx < propertyNames.size(); ++ptIdx)
|
||||
for ( size_t ptIdx = 0; ptIdx < propertyNames.size(); ++ptIdx )
|
||||
{
|
||||
socketStream << propertyNames[ptIdx];
|
||||
socketStream << propertyTypes[ptIdx];
|
||||
@@ -288,45 +312,51 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetNNCPropertyNames_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetNNCPropertyNames>(RiaGetNNCPropertyNames::commandName());
|
||||
static bool RiaGetNNCPropertyNames_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetNNCPropertyNames>(
|
||||
RiaGetNNCPropertyNames::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaSetNNCProperty: public RiaSocketCommand
|
||||
class RiaSetNNCProperty : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
RiaSetNNCProperty() :
|
||||
m_currentReservoir(nullptr),
|
||||
m_currentEclResultAddress(),
|
||||
m_timeStepCountToRead(0),
|
||||
m_bytesPerTimeStepToRead(0),
|
||||
m_currentTimeStepNumberToRead(0),
|
||||
m_invalidConnectionCountDetected(false),
|
||||
m_porosityModelEnum(RiaDefines::MATRIX_MODEL)
|
||||
{}
|
||||
|
||||
static QString commandName () { return QString("SetNNCProperty"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
RiaSetNNCProperty()
|
||||
: m_currentReservoir( nullptr )
|
||||
, m_currentEclResultAddress()
|
||||
, m_timeStepCountToRead( 0 )
|
||||
, m_bytesPerTimeStepToRead( 0 )
|
||||
, m_currentTimeStepNumberToRead( 0 )
|
||||
, m_invalidConnectionCountDetected( false )
|
||||
, m_porosityModelEnum( RiaDefines::MATRIX_MODEL )
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
}
|
||||
|
||||
static QString commandName()
|
||||
{
|
||||
return QString( "SetNNCProperty" );
|
||||
}
|
||||
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs( server, args );
|
||||
|
||||
QString propertyName = args[2];
|
||||
|
||||
// Find the requested data, or create a set if we are setting data and it is not found
|
||||
if (!(rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid()))
|
||||
if ( !( rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid() ) )
|
||||
{
|
||||
QString caseId = args[1];
|
||||
server->showErrorMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find case with id %1").arg(caseId));
|
||||
server->showErrorMessage( RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr( "Could not find case with id %1" ).arg( caseId ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we have not read the header and there are data enough: Read it.
|
||||
// Do nothing if we have not enough data
|
||||
if (m_timeStepCountToRead == 0 || m_bytesPerTimeStepToRead == 0)
|
||||
if ( m_timeStepCountToRead == 0 || m_bytesPerTimeStepToRead == 0 )
|
||||
{
|
||||
if (server->currentClient()->bytesAvailable() < (int)sizeof(quint64)*2) return true;
|
||||
if ( server->currentClient()->bytesAvailable() < (int)sizeof( quint64 ) * 2 ) return true;
|
||||
|
||||
socketStream >> m_timeStepCountToRead;
|
||||
socketStream >> m_bytesPerTimeStepToRead;
|
||||
@@ -334,48 +364,50 @@ public:
|
||||
|
||||
RigNNCData* nncData = rimCase->eclipseCaseData()->mainGrid()->nncData();
|
||||
|
||||
auto nncResults = nncData->generatedConnectionScalarResultByName(propertyName);
|
||||
auto nncResults = nncData->generatedConnectionScalarResultByName( propertyName );
|
||||
|
||||
if (nncResults == nullptr)
|
||||
if ( nncResults == nullptr )
|
||||
{
|
||||
nncData->makeGeneratedConnectionScalarResult(propertyName, m_timeStepCountToRead);
|
||||
nncData->makeGeneratedConnectionScalarResult( propertyName, m_timeStepCountToRead );
|
||||
}
|
||||
|
||||
if (rimCase && rimCase->results(m_porosityModelEnum))
|
||||
if ( rimCase && rimCase->results( m_porosityModelEnum ) )
|
||||
{
|
||||
bool ok = createIJKCellResults(rimCase->results(m_porosityModelEnum), propertyName);
|
||||
if (!ok)
|
||||
bool ok = createIJKCellResults( rimCase->results( m_porosityModelEnum ), propertyName );
|
||||
if ( !ok )
|
||||
{
|
||||
server->showErrorMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the property named: \"%2\"").arg(propertyName));
|
||||
server->showErrorMessage(
|
||||
RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr( "Could not find the property named: \"%2\"" ).arg( propertyName ) );
|
||||
return true;
|
||||
}
|
||||
RigEclipseResultAddress resAddr(QString("%1IJK").arg(propertyName));
|
||||
rimCase->results(m_porosityModelEnum)->ensureKnownResultLoaded(resAddr);
|
||||
nncData->setEclResultAddress(propertyName, resAddr);
|
||||
RigEclipseResultAddress resAddr( QString( "%1IJK" ).arg( propertyName ) );
|
||||
rimCase->results( m_porosityModelEnum )->ensureKnownResultLoaded( resAddr );
|
||||
nncData->setEclResultAddress( propertyName, resAddr );
|
||||
}
|
||||
|
||||
// Create a list of all the requested time steps
|
||||
m_requestedTimesteps.clear();
|
||||
|
||||
if (args.size() <= 4)
|
||||
if ( args.size() <= 4 )
|
||||
{
|
||||
// Select all
|
||||
for (size_t tsIdx = 0; tsIdx < m_timeStepCountToRead; ++tsIdx)
|
||||
for ( size_t tsIdx = 0; tsIdx < m_timeStepCountToRead; ++tsIdx )
|
||||
{
|
||||
m_requestedTimesteps.push_back(tsIdx);
|
||||
m_requestedTimesteps.push_back( tsIdx );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool timeStepReadError = false;
|
||||
for (int argIdx = 4; argIdx < args.size(); ++argIdx)
|
||||
for ( int argIdx = 4; argIdx < args.size(); ++argIdx )
|
||||
{
|
||||
bool conversionOk = false;
|
||||
int tsIdx = args[argIdx].toInt(&conversionOk);
|
||||
int tsIdx = args[argIdx].toInt( &conversionOk );
|
||||
|
||||
if (conversionOk)
|
||||
if ( conversionOk )
|
||||
{
|
||||
m_requestedTimesteps.push_back(tsIdx);
|
||||
m_requestedTimesteps.push_back( tsIdx );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -383,122 +415,135 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (timeStepReadError)
|
||||
if ( timeStepReadError )
|
||||
{
|
||||
server->showErrorMessage(RiaSocketServer::tr("ResInsight SocketServer: riSetNNCProperty : \n") +
|
||||
RiaSocketServer::tr("An error occurred while interpreting the requested time steps."));
|
||||
server->showErrorMessage(
|
||||
RiaSocketServer::tr( "ResInsight SocketServer: riSetNNCProperty : \n" ) +
|
||||
RiaSocketServer::tr( "An error occurred while interpreting the requested time steps." ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (! m_requestedTimesteps.size())
|
||||
if ( !m_requestedTimesteps.size() )
|
||||
{
|
||||
server->showErrorMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("No time steps specified"));
|
||||
server->showErrorMessage( RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr( "No time steps specified" ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
m_currentReservoir = rimCase;
|
||||
m_currentReservoir = rimCase;
|
||||
m_currentPropertyName = propertyName;
|
||||
|
||||
if (server->currentClient()->bytesAvailable())
|
||||
if ( server->currentClient()->bytesAvailable() )
|
||||
{
|
||||
return this->interpretMore(server, server->currentClient());
|
||||
return this->interpretMore( server, server->currentClient() );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
static bool createIJKCellResults(RigCaseCellResultsData* results, QString propertyName)
|
||||
static bool createIJKCellResults( RigCaseCellResultsData* results, QString propertyName )
|
||||
{
|
||||
bool ok;
|
||||
ok = scalarResultExistsOrCreate(results, QString("%1IJK").arg(propertyName));
|
||||
if (!ok) return false;
|
||||
ok = scalarResultExistsOrCreate(results, QString("%1I").arg(propertyName));
|
||||
if (!ok) return false;
|
||||
ok = scalarResultExistsOrCreate(results, QString("%1J").arg(propertyName));
|
||||
if (!ok) return false;
|
||||
ok = scalarResultExistsOrCreate(results, QString("%1K").arg(propertyName));
|
||||
ok = scalarResultExistsOrCreate( results, QString( "%1IJK" ).arg( propertyName ) );
|
||||
if ( !ok ) return false;
|
||||
ok = scalarResultExistsOrCreate( results, QString( "%1I" ).arg( propertyName ) );
|
||||
if ( !ok ) return false;
|
||||
ok = scalarResultExistsOrCreate( results, QString( "%1J" ).arg( propertyName ) );
|
||||
if ( !ok ) return false;
|
||||
ok = scalarResultExistsOrCreate( results, QString( "%1K" ).arg( propertyName ) );
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static bool scalarResultExistsOrCreate(RigCaseCellResultsData* results, QString propertyName)
|
||||
static bool scalarResultExistsOrCreate( RigCaseCellResultsData* results, QString propertyName )
|
||||
{
|
||||
RigEclipseResultAddress resAddr(RiaDefines::GENERATED, propertyName);
|
||||
RigEclipseResultAddress resAddr( RiaDefines::GENERATED, propertyName );
|
||||
|
||||
if ( !results->ensureKnownResultLoaded(resAddr) )
|
||||
if ( !results->ensureKnownResultLoaded( resAddr ) )
|
||||
{
|
||||
results->createResultEntry(resAddr, true);
|
||||
results->createResultEntry( resAddr, true );
|
||||
}
|
||||
|
||||
std::vector< std::vector<double> >* scalarResultFrames = nullptr;
|
||||
scalarResultFrames = &(results->modifiableCellScalarResultTimesteps(resAddr));
|
||||
std::vector<std::vector<double>>* scalarResultFrames = nullptr;
|
||||
scalarResultFrames = &( results->modifiableCellScalarResultTimesteps( resAddr ) );
|
||||
size_t timeStepCount = results->maxTimeStepCount();
|
||||
scalarResultFrames->resize(timeStepCount);
|
||||
scalarResultFrames->resize( timeStepCount );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
bool interpretMore(RiaSocketServer* server, QTcpSocket* currentClient) override
|
||||
bool interpretMore( RiaSocketServer* server, QTcpSocket* currentClient ) override
|
||||
{
|
||||
if (m_invalidConnectionCountDetected) return true;
|
||||
if ( m_invalidConnectionCountDetected ) return true;
|
||||
|
||||
// If nothing should be read, or we already have read everything, do nothing
|
||||
if ((m_timeStepCountToRead == 0) || (m_currentTimeStepNumberToRead >= m_timeStepCountToRead) ) return true;
|
||||
if ( ( m_timeStepCountToRead == 0 ) || ( m_currentTimeStepNumberToRead >= m_timeStepCountToRead ) ) return true;
|
||||
|
||||
if (!currentClient->bytesAvailable()) return false;
|
||||
if ( !currentClient->bytesAvailable() ) return false;
|
||||
|
||||
if (m_timeStepCountToRead != m_requestedTimesteps.size())
|
||||
if ( m_timeStepCountToRead != m_requestedTimesteps.size() )
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
CVF_ASSERT( false );
|
||||
}
|
||||
|
||||
// Check if a complete timestep is available, return and whait for readyRead() if not
|
||||
if (currentClient->bytesAvailable() < (int)m_bytesPerTimeStepToRead) return false;
|
||||
if ( currentClient->bytesAvailable() < (int)m_bytesPerTimeStepToRead ) return false;
|
||||
|
||||
RigNNCData* nncData = m_currentReservoir->eclipseCaseData()->mainGrid()->nncData();
|
||||
|
||||
size_t connectionCountFromOctave = m_bytesPerTimeStepToRead / sizeof(double);
|
||||
size_t connectionCount = nncData->connections().size();
|
||||
std::vector< std::vector<double> >* resultsToAdd = nncData->generatedConnectionScalarResultByName(m_currentPropertyName);
|
||||
size_t connectionCountFromOctave = m_bytesPerTimeStepToRead / sizeof( double );
|
||||
size_t connectionCount = nncData->connections().size();
|
||||
std::vector<std::vector<double>>* resultsToAdd = nncData->generatedConnectionScalarResultByName(
|
||||
m_currentPropertyName );
|
||||
|
||||
if (connectionCountFromOctave != connectionCount)
|
||||
if ( connectionCountFromOctave != connectionCount )
|
||||
{
|
||||
server->showErrorMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") +
|
||||
RiaSocketServer::tr("The number of connections in the data coming from octave does not match the case: '%1'\n").arg(m_currentReservoir->caseUserDescription()) +
|
||||
RiaSocketServer::tr(" Octave: %1\n").arg(connectionCountFromOctave) +
|
||||
RiaSocketServer::tr(" %1: Connection count: %2").arg(m_currentReservoir->caseUserDescription()).arg(connectionCount));
|
||||
server->showErrorMessage(
|
||||
RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr(
|
||||
"The number of connections in the data coming from octave does not match the case: '%1'\n" )
|
||||
.arg( m_currentReservoir->caseUserDescription() ) +
|
||||
RiaSocketServer::tr( " Octave: %1\n" ).arg( connectionCountFromOctave ) +
|
||||
RiaSocketServer::tr( " %1: Connection count: %2" )
|
||||
.arg( m_currentReservoir->caseUserDescription() )
|
||||
.arg( connectionCount ) );
|
||||
|
||||
connectionCountFromOctave = 0;
|
||||
connectionCountFromOctave = 0;
|
||||
m_invalidConnectionCountDetected = true;
|
||||
currentClient->abort();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
for (size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx)
|
||||
for ( size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx )
|
||||
{
|
||||
size_t tsId = m_requestedTimesteps[tIdx];
|
||||
resultsToAdd->at(tsId).resize(connectionCount, HUGE_VAL);
|
||||
resultsToAdd->at( tsId ).resize( connectionCount, HUGE_VAL );
|
||||
}
|
||||
|
||||
double* internalMatrixData = nullptr;
|
||||
|
||||
QDataStream socketStream(currentClient);
|
||||
socketStream.setVersion(riOctavePlugin::qtDataStreamVersion);
|
||||
QDataStream socketStream( currentClient );
|
||||
socketStream.setVersion( riOctavePlugin::qtDataStreamVersion );
|
||||
|
||||
// Read available complete time step data
|
||||
while ((currentClient->bytesAvailable() >= (int)m_bytesPerTimeStepToRead) && (m_currentTimeStepNumberToRead < m_timeStepCountToRead))
|
||||
while ( ( currentClient->bytesAvailable() >= (int)m_bytesPerTimeStepToRead ) &&
|
||||
( m_currentTimeStepNumberToRead < m_timeStepCountToRead ) )
|
||||
{
|
||||
internalMatrixData = resultsToAdd->at(m_requestedTimesteps[m_currentTimeStepNumberToRead]).data();
|
||||
internalMatrixData = resultsToAdd->at( m_requestedTimesteps[m_currentTimeStepNumberToRead] ).data();
|
||||
|
||||
QStringList errorMessages;
|
||||
if (!RiaSocketDataTransfer::readBlockDataFromSocket(currentClient, (char*)(internalMatrixData), m_bytesPerTimeStepToRead, errorMessages))
|
||||
if ( !RiaSocketDataTransfer::readBlockDataFromSocket( currentClient,
|
||||
(char*)( internalMatrixData ),
|
||||
m_bytesPerTimeStepToRead,
|
||||
errorMessages ) )
|
||||
{
|
||||
for (int i = 0; i < errorMessages.size(); i++)
|
||||
for ( int i = 0; i < errorMessages.size(); i++ )
|
||||
{
|
||||
server->showErrorMessage(errorMessages[i]);
|
||||
server->showErrorMessage( errorMessages[i] );
|
||||
}
|
||||
|
||||
currentClient->abort();
|
||||
@@ -507,48 +552,53 @@ public:
|
||||
++m_currentTimeStepNumberToRead;
|
||||
}
|
||||
|
||||
|
||||
// If we have read all the data, refresh the views
|
||||
|
||||
if (m_currentTimeStepNumberToRead == m_timeStepCountToRead)
|
||||
if ( m_currentTimeStepNumberToRead == m_timeStepCountToRead )
|
||||
{
|
||||
if (m_currentReservoir != nullptr)
|
||||
if ( m_currentReservoir != nullptr )
|
||||
{
|
||||
// Create a new input property if we have an input reservoir
|
||||
RimEclipseInputCase* inputRes = dynamic_cast<RimEclipseInputCase*>(m_currentReservoir);
|
||||
if (inputRes)
|
||||
RimEclipseInputCase* inputRes = dynamic_cast<RimEclipseInputCase*>( m_currentReservoir );
|
||||
if ( inputRes )
|
||||
{
|
||||
RimEclipseInputProperty* inputProperty = inputRes->inputPropertyCollection()->findInputProperty(m_currentPropertyName);
|
||||
if (!inputProperty)
|
||||
RimEclipseInputProperty* inputProperty = inputRes->inputPropertyCollection()->findInputProperty(
|
||||
m_currentPropertyName );
|
||||
if ( !inputProperty )
|
||||
{
|
||||
inputProperty = new RimEclipseInputProperty;
|
||||
inputProperty->resultName = m_currentPropertyName;
|
||||
inputProperty = new RimEclipseInputProperty;
|
||||
inputProperty->resultName = m_currentPropertyName;
|
||||
inputProperty->eclipseKeyword = "";
|
||||
inputProperty->fileName = "";
|
||||
inputRes->inputPropertyCollection()->inputProperties.push_back(inputProperty);
|
||||
inputProperty->fileName = "";
|
||||
inputRes->inputPropertyCollection()->inputProperties.push_back( inputProperty );
|
||||
inputRes->inputPropertyCollection()->updateConnectedEditors();
|
||||
}
|
||||
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED_NOT_SAVED;
|
||||
}
|
||||
|
||||
if( m_currentEclResultAddress.isValid() && // Will never be valid because it is never set. What is correct behaviour ?
|
||||
m_currentReservoir->eclipseCaseData() &&
|
||||
m_currentReservoir->eclipseCaseData()->results(m_porosityModelEnum) )
|
||||
if ( m_currentEclResultAddress
|
||||
.isValid() && // Will never be valid because it is never set. What is correct behaviour ?
|
||||
m_currentReservoir->eclipseCaseData() &&
|
||||
m_currentReservoir->eclipseCaseData()->results( m_porosityModelEnum ) )
|
||||
{
|
||||
m_currentReservoir->eclipseCaseData()->results(m_porosityModelEnum)->recalculateStatistics(m_currentEclResultAddress);
|
||||
m_currentReservoir->eclipseCaseData()
|
||||
->results( m_porosityModelEnum )
|
||||
->recalculateStatistics( m_currentEclResultAddress );
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_currentReservoir->reservoirViews.size(); ++i)
|
||||
for ( size_t i = 0; i < m_currentReservoir->reservoirViews.size(); ++i )
|
||||
{
|
||||
if (m_currentReservoir->reservoirViews[i])
|
||||
if ( m_currentReservoir->reservoirViews[i] )
|
||||
{
|
||||
// As new result might have been introduced, update all editors connected
|
||||
m_currentReservoir->reservoirViews[i]->cellResult()->updateConnectedEditors();
|
||||
|
||||
// It is usually not needed to create new display model, but if any derived geometry based on generated data (from Octave)
|
||||
// a full display model rebuild is required
|
||||
// It is usually not needed to create new display model, but if any derived geometry based on
|
||||
// generated data (from Octave) a full display model rebuild is required
|
||||
m_currentReservoir->reservoirViews[i]->scheduleCreateDisplayModelAndRedraw();
|
||||
m_currentReservoir->reservoirViews[i]->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
|
||||
m_currentReservoir->reservoirViews[i]
|
||||
->crossSectionCollection()
|
||||
->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -557,21 +607,21 @@ public:
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
RimEclipseCase* m_currentReservoir;
|
||||
RigEclipseResultAddress m_currentEclResultAddress;
|
||||
QString m_currentPropertyName;
|
||||
std::vector<size_t> m_requestedTimesteps;
|
||||
RiaDefines::PorosityModelType m_porosityModelEnum;
|
||||
RimEclipseCase* m_currentReservoir;
|
||||
RigEclipseResultAddress m_currentEclResultAddress;
|
||||
QString m_currentPropertyName;
|
||||
std::vector<size_t> m_requestedTimesteps;
|
||||
RiaDefines::PorosityModelType m_porosityModelEnum;
|
||||
|
||||
quint64 m_timeStepCountToRead;
|
||||
quint64 m_bytesPerTimeStepToRead;
|
||||
size_t m_currentTimeStepNumberToRead;
|
||||
quint64 m_timeStepCountToRead;
|
||||
quint64 m_bytesPerTimeStepToRead;
|
||||
size_t m_currentTimeStepNumberToRead;
|
||||
|
||||
bool m_invalidConnectionCountDetected;
|
||||
bool m_invalidConnectionCountDetected;
|
||||
};
|
||||
|
||||
static bool RiaSetNNCProperty_init = RiaSocketCommandFactory::instance()->registerCreator<RiaSetNNCProperty>(RiaSetNNCProperty::commandName());
|
||||
static bool RiaSetNNCProperty_init = RiaSocketCommandFactory::instance()->registerCreator<RiaSetNNCProperty>(
|
||||
RiaSetNNCProperty::commandName() );
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron AS
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -44,14 +44,16 @@
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void getCaseInfoFromCases(std::vector<RimCase*>& cases, std::vector<qint64>& caseIds, std::vector<QString>& caseNames, std::vector<QString> &caseTypes, std::vector<qint64>& caseGroupIds)
|
||||
void getCaseInfoFromCases( std::vector<RimCase*>& cases,
|
||||
std::vector<qint64>& caseIds,
|
||||
std::vector<QString>& caseNames,
|
||||
std::vector<QString>& caseTypes,
|
||||
std::vector<qint64>& caseGroupIds )
|
||||
{
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
for ( size_t i = 0; i < cases.size(); i++ )
|
||||
{
|
||||
RimCase* rimCase = cases[i];
|
||||
|
||||
@@ -59,40 +61,42 @@ void getCaseInfoFromCases(std::vector<RimCase*>& cases, std::vector<qint64>& cas
|
||||
QString caseName;
|
||||
QString caseType;
|
||||
qint64 caseGroupId = -1;
|
||||
RiaSocketTools::getCaseInfoFromCase(rimCase, caseId, caseName, caseType, caseGroupId);
|
||||
RiaSocketTools::getCaseInfoFromCase( rimCase, caseId, caseName, caseType, caseGroupId );
|
||||
|
||||
caseIds.push_back(rimCase->caseId);
|
||||
caseNames.push_back(rimCase->caseUserDescription);
|
||||
caseTypes.push_back(caseType);
|
||||
caseGroupIds.push_back(caseGroupId);
|
||||
caseIds.push_back( rimCase->caseId );
|
||||
caseNames.push_back( rimCase->caseUserDescription );
|
||||
caseTypes.push_back( caseType );
|
||||
caseGroupIds.push_back( caseGroupId );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetCurrentCase : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetCurrentCase"); }
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
return QString( "GetCurrentCase" );
|
||||
}
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
qint64 caseId = server->currentCaseId();
|
||||
QString caseName;
|
||||
QString caseType;
|
||||
qint64 caseGroupId = -1;
|
||||
|
||||
RimEclipseCase* rimCase = server->findReservoir(caseId);
|
||||
RimEclipseCase* rimCase = server->findReservoir( caseId );
|
||||
|
||||
if (rimCase)
|
||||
if ( rimCase )
|
||||
{
|
||||
RiaSocketTools::getCaseInfoFromCase(rimCase, caseId, caseName, caseType, caseGroupId);
|
||||
RiaSocketTools::getCaseInfoFromCase( rimCase, caseId, caseName, caseType, caseGroupId );
|
||||
}
|
||||
|
||||
quint64 byteCount = 2*sizeof(qint64);
|
||||
byteCount += caseName.size()*sizeof(QChar);
|
||||
byteCount += caseType.size()*sizeof(QChar);
|
||||
quint64 byteCount = 2 * sizeof( qint64 );
|
||||
byteCount += caseName.size() * sizeof( QChar );
|
||||
byteCount += caseType.size() * sizeof( QChar );
|
||||
|
||||
socketStream << byteCount;
|
||||
|
||||
@@ -102,50 +106,50 @@ public:
|
||||
socketStream << caseGroupId;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static bool RiaGetCurrentCase_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCurrentCase>(RiaGetCurrentCase::commandName());
|
||||
|
||||
|
||||
static bool RiaGetCurrentCase_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCurrentCase>(
|
||||
RiaGetCurrentCase::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetSelectedCases: public RiaSocketCommand
|
||||
class RiaGetSelectedCases : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetSelectedCases"); }
|
||||
static QString commandName()
|
||||
{
|
||||
return QString( "GetSelectedCases" );
|
||||
}
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
{
|
||||
std::vector<RimCase*> cases;
|
||||
caf::SelectionManager::instance()->objectsByType(&cases);
|
||||
caf::SelectionManager::instance()->objectsByType( &cases );
|
||||
|
||||
std::vector<qint64> caseIds;
|
||||
std::vector<QString> caseNames;
|
||||
std::vector<QString> caseTypes;
|
||||
std::vector<QString> caseTypes;
|
||||
std::vector<qint64> caseGroupIds;
|
||||
|
||||
getCaseInfoFromCases(cases, caseIds, caseNames, caseTypes, caseGroupIds);
|
||||
getCaseInfoFromCases( cases, caseIds, caseNames, caseTypes, caseGroupIds );
|
||||
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
quint64 byteCount = sizeof( quint64 );
|
||||
quint64 selectionCount = caseIds.size();
|
||||
|
||||
for (size_t i = 0; i < selectionCount; i++)
|
||||
for ( size_t i = 0; i < selectionCount; i++ )
|
||||
{
|
||||
byteCount += 2*sizeof(qint64);
|
||||
byteCount += caseNames[i].size() * sizeof(QChar);
|
||||
byteCount += caseTypes[i].size() * sizeof(QChar);
|
||||
byteCount += 2 * sizeof( qint64 );
|
||||
byteCount += caseNames[i].size() * sizeof( QChar );
|
||||
byteCount += caseTypes[i].size() * sizeof( QChar );
|
||||
}
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << selectionCount;
|
||||
|
||||
for (size_t i = 0; i < selectionCount; i++)
|
||||
for ( size_t i = 0; i < selectionCount; i++ )
|
||||
{
|
||||
socketStream << caseIds[i];
|
||||
socketStream << caseNames[i];
|
||||
@@ -158,8 +162,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetSelectedCases_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetSelectedCases>(RiaGetSelectedCases::commandName());
|
||||
|
||||
static bool RiaGetSelectedCases_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetSelectedCases>(
|
||||
RiaGetSelectedCases::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -167,37 +171,42 @@ static bool RiaGetSelectedCases_init = RiaSocketCommandFactory::instance()->regi
|
||||
class RiaGetCaseGroups : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetCaseGroups"); }
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
RimEclipseCaseCollection* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : nullptr;
|
||||
if (analysisModels)
|
||||
return QString( "GetCaseGroups" );
|
||||
}
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
RimEclipseCaseCollection* analysisModels = ( proj && proj->activeOilField() )
|
||||
? proj->activeOilField()->analysisModels()
|
||||
: nullptr;
|
||||
if ( analysisModels )
|
||||
{
|
||||
std::vector<QString> groupNames;
|
||||
std::vector<qint64> groupIds;
|
||||
std::vector<qint64> groupIds;
|
||||
|
||||
size_t caseGroupCount = analysisModels->caseGroups().size();
|
||||
quint64 byteCount = 0;
|
||||
size_t caseGroupCount = analysisModels->caseGroups().size();
|
||||
quint64 byteCount = 0;
|
||||
|
||||
for (size_t i = 0; i < caseGroupCount; i++)
|
||||
for ( size_t i = 0; i < caseGroupCount; i++ )
|
||||
{
|
||||
RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups()[i];
|
||||
|
||||
QString caseGroupName = cg->name;
|
||||
qint64 caseGroupId = cg->groupId;
|
||||
qint64 caseGroupId = cg->groupId;
|
||||
|
||||
byteCount += caseGroupName.size() * sizeof(QChar);
|
||||
byteCount += sizeof(qint64);
|
||||
byteCount += caseGroupName.size() * sizeof( QChar );
|
||||
byteCount += sizeof( qint64 );
|
||||
|
||||
groupNames.push_back(caseGroupName);
|
||||
groupIds.push_back(caseGroupId);
|
||||
groupNames.push_back( caseGroupName );
|
||||
groupIds.push_back( caseGroupId );
|
||||
}
|
||||
|
||||
socketStream << (quint64)byteCount;
|
||||
socketStream << (quint64)caseGroupCount;
|
||||
|
||||
for (size_t i = 0; i < caseGroupCount; i++)
|
||||
for ( size_t i = 0; i < caseGroupCount; i++ )
|
||||
{
|
||||
socketStream << groupNames[i];
|
||||
socketStream << groupIds[i];
|
||||
@@ -210,13 +219,10 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static bool RiaGetCaseGroups_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCaseGroups>(RiaGetCaseGroups::commandName());
|
||||
|
||||
|
||||
|
||||
static bool RiaGetCaseGroups_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCaseGroups>(
|
||||
RiaGetCaseGroups::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -224,76 +230,79 @@ static bool RiaGetCaseGroups_init = RiaSocketCommandFactory::instance()->registe
|
||||
class RiaGetCases : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetCases"); }
|
||||
static QString commandName()
|
||||
{
|
||||
return QString( "GetCases" );
|
||||
}
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
|
||||
if (args.size() == 2)
|
||||
if ( args.size() == 2 )
|
||||
{
|
||||
argCaseGroupId = args[1].toInt();
|
||||
}
|
||||
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
RimEclipseCaseCollection* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : nullptr;
|
||||
if (analysisModels)
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
RimEclipseCaseCollection* analysisModels = ( proj && proj->activeOilField() )
|
||||
? proj->activeOilField()->analysisModels()
|
||||
: nullptr;
|
||||
if ( analysisModels )
|
||||
{
|
||||
|
||||
std::vector<RimCase*> cases;
|
||||
if (argCaseGroupId == -1)
|
||||
if ( argCaseGroupId == -1 )
|
||||
{
|
||||
proj->allCases(cases);
|
||||
proj->allCases( cases );
|
||||
}
|
||||
else
|
||||
{
|
||||
RimIdenticalGridCaseGroup* caseGroup = nullptr;
|
||||
for (size_t i = 0; i < analysisModels->caseGroups().size(); i++)
|
||||
for ( size_t i = 0; i < analysisModels->caseGroups().size(); i++ )
|
||||
{
|
||||
RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups()[i];
|
||||
|
||||
if (argCaseGroupId == cg->groupId())
|
||||
if ( argCaseGroupId == cg->groupId() )
|
||||
{
|
||||
caseGroup = cg;
|
||||
}
|
||||
}
|
||||
|
||||
if (caseGroup)
|
||||
if ( caseGroup )
|
||||
{
|
||||
for (size_t i = 0; i < caseGroup->statisticsCaseCollection()->reservoirs.size(); i++)
|
||||
for ( size_t i = 0; i < caseGroup->statisticsCaseCollection()->reservoirs.size(); i++ )
|
||||
{
|
||||
cases.push_back(caseGroup->statisticsCaseCollection()->reservoirs[i]);
|
||||
cases.push_back( caseGroup->statisticsCaseCollection()->reservoirs[i] );
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < caseGroup->caseCollection()->reservoirs.size(); i++)
|
||||
for ( size_t i = 0; i < caseGroup->caseCollection()->reservoirs.size(); i++ )
|
||||
{
|
||||
cases.push_back(caseGroup->caseCollection()->reservoirs[i]);
|
||||
cases.push_back( caseGroup->caseCollection()->reservoirs[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<qint64> caseIds;
|
||||
std::vector<QString> caseNames;
|
||||
std::vector<QString> caseTypes;
|
||||
std::vector<qint64> caseGroupIds;
|
||||
|
||||
getCaseInfoFromCases(cases, caseIds, caseNames, caseTypes, caseGroupIds);
|
||||
getCaseInfoFromCases( cases, caseIds, caseNames, caseTypes, caseGroupIds );
|
||||
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
quint64 byteCount = sizeof( quint64 );
|
||||
quint64 caseCount = caseIds.size();
|
||||
|
||||
for (size_t i = 0; i < caseCount; i++)
|
||||
for ( size_t i = 0; i < caseCount; i++ )
|
||||
{
|
||||
byteCount += 2*sizeof(qint64);
|
||||
byteCount += caseNames[i].size() * sizeof(QChar);
|
||||
byteCount += caseTypes[i].size() * sizeof(QChar);
|
||||
byteCount += 2 * sizeof( qint64 );
|
||||
byteCount += caseNames[i].size() * sizeof( QChar );
|
||||
byteCount += caseTypes[i].size() * sizeof( QChar );
|
||||
}
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << caseCount;
|
||||
|
||||
for (size_t i = 0; i < caseCount; i++)
|
||||
for ( size_t i = 0; i < caseCount; i++ )
|
||||
{
|
||||
socketStream << caseIds[i];
|
||||
socketStream << caseNames[i];
|
||||
@@ -306,4 +315,5 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetCases_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCases>(RiaGetCases::commandName());
|
||||
static bool RiaGetCases_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCases>(
|
||||
RiaGetCases::commandName() );
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// The base class for classes interpreting commands sent via socket.
|
||||
/// Works in close connection with RiaSocketServer
|
||||
@@ -38,20 +37,21 @@ public:
|
||||
virtual ~RiaSocketCommand() {}
|
||||
|
||||
/// This method is supposed to interpret the commands received from the calling socket connection and
|
||||
/// read the data currently available.
|
||||
/// If it read all the data and completed the command, it is supposed to return true. If it did not read all the data,
|
||||
/// it is supposed to return false. The socket server will then assume that the command is not completely interpreted,
|
||||
/// and will continue to call interpretMore() until that method returns true.
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) = 0;
|
||||
/// read the data currently available.
|
||||
/// If it read all the data and completed the command, it is supposed to return true. If it did not read all the
|
||||
/// data, it is supposed to return false. The socket server will then assume that the command is not completely
|
||||
/// interpreted, and will continue to call interpretMore() until that method returns true.
|
||||
|
||||
/// This method is supposed to read whatever more data that is available on the socket connection, and return true if it
|
||||
/// was able to read all the data. If not all the data was available, it must return false, so that the RiaSocketServer
|
||||
/// will call this method again when more data becomes available.
|
||||
virtual bool interpretMore(RiaSocketServer* server, QTcpSocket* currentClient) { return true; }
|
||||
virtual bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) = 0;
|
||||
|
||||
/// This method is supposed to read whatever more data that is available on the socket connection, and return true
|
||||
/// if it was able to read all the data. If not all the data was available, it must return false, so that the
|
||||
/// RiaSocketServer will call this method again when more data becomes available.
|
||||
virtual bool interpretMore( RiaSocketServer* server, QTcpSocket* currentClient )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#include "cafFactory.h"
|
||||
typedef caf::Factory<RiaSocketCommand, QString> RiaSocketCommandFactory;
|
||||
|
||||
|
||||
|
||||
@@ -2,74 +2,78 @@
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
// Copyright (C) Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaSocketDataTransfer.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaSocketDataTransfer::writeBlockDataToSocket(QTcpSocket* socket, const char* data, quint64 bytesToWrite, QStringList& errorMessages)
|
||||
bool RiaSocketDataTransfer::writeBlockDataToSocket( QTcpSocket* socket,
|
||||
const char* data,
|
||||
quint64 bytesToWrite,
|
||||
QStringList& errorMessages )
|
||||
{
|
||||
quint64 bytesWritten = 0;
|
||||
|
||||
quint64 maxBlockSize = maximumValueCountInBlock() * sizeof(double);
|
||||
quint64 maxBlockSize = maximumValueCountInBlock() * sizeof( double );
|
||||
|
||||
while (bytesWritten < bytesToWrite)
|
||||
while ( bytesWritten < bytesToWrite )
|
||||
{
|
||||
quint64 byteCountToWrite = qMin(bytesToWrite - bytesWritten, maxBlockSize);
|
||||
quint64 byteCountToWrite = qMin( bytesToWrite - bytesWritten, maxBlockSize );
|
||||
|
||||
qint64 actuallyBytesWritten = socket->write(data + bytesWritten, byteCountToWrite);
|
||||
if (actuallyBytesWritten < 0)
|
||||
qint64 actuallyBytesWritten = socket->write( data + bytesWritten, byteCountToWrite );
|
||||
if ( actuallyBytesWritten < 0 )
|
||||
{
|
||||
errorMessages.push_back("Error detected when writing data, error string from socket");
|
||||
errorMessages.push_back(socket->errorString());
|
||||
errorMessages.push_back( "Error detected when writing data, error string from socket" );
|
||||
errorMessages.push_back( socket->errorString() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bytesWritten += actuallyBytesWritten;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaSocketDataTransfer::readBlockDataFromSocket(QTcpSocket* socket, char* data, quint64 bytesToRead, QStringList& errorMessages)
|
||||
bool RiaSocketDataTransfer::readBlockDataFromSocket( QTcpSocket* socket,
|
||||
char* data,
|
||||
quint64 bytesToRead,
|
||||
QStringList& errorMessages )
|
||||
{
|
||||
quint64 bytesRead = 0;
|
||||
|
||||
quint64 maxBlockSize = maximumValueCountInBlock() * sizeof(double);
|
||||
quint64 maxBlockSize = maximumValueCountInBlock() * sizeof( double );
|
||||
|
||||
while (bytesRead < bytesToRead)
|
||||
while ( bytesRead < bytesToRead )
|
||||
{
|
||||
if (socket->bytesAvailable())
|
||||
if ( socket->bytesAvailable() )
|
||||
{
|
||||
quint64 byteCountToRead = bytesToRead - bytesRead;
|
||||
byteCountToRead = qMin(byteCountToRead, maxBlockSize);
|
||||
byteCountToRead = qMin( byteCountToRead, maxBlockSize );
|
||||
|
||||
qint64 actuallyBytesRead = socket->read(data + bytesRead, byteCountToRead);
|
||||
if (actuallyBytesRead < 0)
|
||||
qint64 actuallyBytesRead = socket->read( data + bytesRead, byteCountToRead );
|
||||
if ( actuallyBytesRead < 0 )
|
||||
{
|
||||
errorMessages.push_back("Error detected when reading data, error string from socket");
|
||||
errorMessages.push_back(socket->errorString());
|
||||
errorMessages.push_back( "Error detected when reading data, error string from socket" );
|
||||
errorMessages.push_back( socket->errorString() );
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -77,15 +81,15 @@ bool RiaSocketDataTransfer::readBlockDataFromSocket(QTcpSocket* socket, char* da
|
||||
bytesRead += actuallyBytesRead;
|
||||
|
||||
#ifdef octave_oct_h
|
||||
//octave_stdout << "Byte read " << bytesRead << " of a total of "<< bytesToRead << "\n";
|
||||
// octave_stdout << "Byte read " << bytesRead << " of a total of "<< bytesToRead << "\n";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!socket->waitForReadyRead())
|
||||
if ( !socket->waitForReadyRead() )
|
||||
{
|
||||
errorMessages.push_back("Waited for data for %1 milli seconds.");
|
||||
errorMessages.push_back(socket->errorString());
|
||||
errorMessages.push_back( "Waited for data for %1 milli seconds." );
|
||||
errorMessages.push_back( socket->errorString() );
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -95,18 +99,15 @@ bool RiaSocketDataTransfer::readBlockDataFromSocket(QTcpSocket* socket, char* da
|
||||
#ifdef octave_oct_h
|
||||
OCTAVE_QUIT;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RiaSocketDataTransfer::maximumValueCountInBlock()
|
||||
{
|
||||
return 20000;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,30 +2,30 @@
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
// Copyright (C) Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QTcpSocket>
|
||||
#include <QStringList>
|
||||
#include <QTcpSocket>
|
||||
|
||||
//==================================================================================================
|
||||
/// Utility class used for transfer of data using QTcpSocket
|
||||
///
|
||||
/// As the compile configuration for octave plugins is quite complex,
|
||||
/// As the compile configuration for octave plugins is quite complex,
|
||||
// the octave plugins includes the cpp-file to be able to compile only one file per plugin
|
||||
//==================================================================================================
|
||||
class RiaSocketDataTransfer
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
static size_t maximumValueCountInBlock();
|
||||
|
||||
public:
|
||||
static bool writeBlockDataToSocket(QTcpSocket* socket, const char* data, quint64 bytesToWrite, QStringList& errorMessages);
|
||||
static bool readBlockDataFromSocket(QTcpSocket* socket, char* data, quint64 bytesToRead, QStringList& errorMessages);
|
||||
static bool
|
||||
writeBlockDataToSocket( QTcpSocket* socket, const char* data, quint64 bytesToWrite, QStringList& errorMessages );
|
||||
static bool readBlockDataFromSocket( QTcpSocket* socket, char* data, quint64 bytesToRead, QStringList& errorMessages );
|
||||
};
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron AS
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -25,10 +25,10 @@
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimCase.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuViewer.h"
|
||||
@@ -44,27 +44,26 @@
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaSocketServer::RiaSocketServer(QObject* parent)
|
||||
: QObject(parent),
|
||||
m_tcpServer(nullptr),
|
||||
m_currentClient(nullptr),
|
||||
m_currentCommandSize(0),
|
||||
m_currentCommand(nullptr),
|
||||
m_currentCaseId(-1)
|
||||
RiaSocketServer::RiaSocketServer( QObject* parent )
|
||||
: QObject( parent )
|
||||
, m_tcpServer( nullptr )
|
||||
, m_currentClient( nullptr )
|
||||
, m_currentCommandSize( 0 )
|
||||
, m_currentCommand( nullptr )
|
||||
, m_currentCaseId( -1 )
|
||||
{
|
||||
// TCP server setup
|
||||
|
||||
m_tcpServer = new QTcpServer(this);
|
||||
m_tcpServer = new QTcpServer( this );
|
||||
|
||||
m_nextPendingConnectionTimer = new QTimer(this);
|
||||
m_nextPendingConnectionTimer->setInterval(100);
|
||||
m_nextPendingConnectionTimer->setSingleShot(true);
|
||||
m_nextPendingConnectionTimer = new QTimer( this );
|
||||
m_nextPendingConnectionTimer->setInterval( 100 );
|
||||
m_nextPendingConnectionTimer->setSingleShot( true );
|
||||
|
||||
if (!m_tcpServer->listen(QHostAddress::LocalHost, 40001))
|
||||
if ( !m_tcpServer->listen( QHostAddress::LocalHost, 40001 ) )
|
||||
{
|
||||
QString txt;
|
||||
txt = "This instance of ResInsight could not start the Socket Server enabling octave to get and set data.\n "
|
||||
@@ -72,15 +71,15 @@ RiaSocketServer::RiaSocketServer(QObject* parent)
|
||||
"Octave can only communicate with one ResInsight process at a time, so the Octave\n"
|
||||
"communication in this ResInsight instance will be disabled.\n"
|
||||
"\n" +
|
||||
tr("The error from the socket system is: %1.").arg(m_tcpServer->errorString());
|
||||
tr( "The error from the socket system is: %1." ).arg( m_tcpServer->errorString() );
|
||||
|
||||
RiaLogging::error(txt);
|
||||
RiaLogging::error( txt );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
connect(m_nextPendingConnectionTimer, SIGNAL(timeout()), this, SLOT(slotNewClientConnection()));
|
||||
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(slotNewClientConnection()));
|
||||
connect( m_nextPendingConnectionTimer, SIGNAL( timeout() ), this, SLOT( slotNewClientConnection() ) );
|
||||
connect( m_tcpServer, SIGNAL( newConnection() ), this, SLOT( slotNewClientConnection() ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -88,7 +87,7 @@ RiaSocketServer::RiaSocketServer(QObject* parent)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaSocketServer::~RiaSocketServer()
|
||||
{
|
||||
assert (m_currentCommand == nullptr);
|
||||
assert( m_currentCommand == nullptr );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -96,8 +95,10 @@ RiaSocketServer::~RiaSocketServer()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
unsigned short RiaSocketServer::serverPort()
|
||||
{
|
||||
if (m_tcpServer) return m_tcpServer->serverPort();
|
||||
else return 0;
|
||||
if ( m_tcpServer )
|
||||
return m_tcpServer->serverPort();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -105,27 +106,27 @@ unsigned short RiaSocketServer::serverPort()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::slotNewClientConnection()
|
||||
{
|
||||
// If we are currently handling a connection, just ignore the new one until the current one is disconnected.
|
||||
// If we are currently handling a connection, just ignore the new one until the current one is disconnected.
|
||||
|
||||
if (m_currentClient && (m_currentClient->state() != QAbstractSocket::UnconnectedState) )
|
||||
if ( m_currentClient && ( m_currentClient->state() != QAbstractSocket::UnconnectedState ) )
|
||||
{
|
||||
//PMonLog("Starting Timer");
|
||||
// PMonLog("Starting Timer");
|
||||
m_nextPendingConnectionTimer->start(); // Reset and start again
|
||||
return;
|
||||
}
|
||||
|
||||
// Read pending data from socket
|
||||
|
||||
if (m_currentClient && m_currentCommand)
|
||||
if ( m_currentClient && m_currentCommand )
|
||||
{
|
||||
bool isFinshed = m_currentCommand->interpretMore(this, m_currentClient);
|
||||
bool isFinshed = m_currentCommand->interpretMore( this, m_currentClient );
|
||||
|
||||
if (!isFinshed)
|
||||
if ( !isFinshed )
|
||||
{
|
||||
QString txt;
|
||||
txt = "ResInsight SocketServer : The command did not finish up correctly at the presence of a new one.";
|
||||
|
||||
RiaLogging::error(txt);
|
||||
|
||||
RiaLogging::error( txt );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,32 +136,32 @@ void RiaSocketServer::slotNewClientConnection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Find the requested reservoir by caseId
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseCase* RiaSocketServer::findReservoir(int caseId)
|
||||
RimEclipseCase* RiaSocketServer::findReservoir( int caseId )
|
||||
{
|
||||
int currCaseId = caseId;
|
||||
if (caseId < 0)
|
||||
if ( caseId < 0 )
|
||||
{
|
||||
currCaseId = this->currentCaseId();
|
||||
}
|
||||
|
||||
if (currCaseId < 0)
|
||||
if ( currCaseId < 0 )
|
||||
{
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
|
||||
if (eclipseView)
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( RiaApplication::instance()->activeReservoirView() );
|
||||
if ( eclipseView )
|
||||
{
|
||||
return eclipseView->eclipseCase();
|
||||
}
|
||||
|
||||
// If the active mdi window is different from an Eclipse view, search through available mdi windows to find the last activated
|
||||
// Eclipse view. The sub windows are returned with the most recent activated window at the back.
|
||||
QList<QMdiSubWindow*> subWindows = RiuMainWindow::instance()->subWindowList(QMdiArea::ActivationHistoryOrder);
|
||||
for (int i = subWindows.size() - 1; i > -1; i--)
|
||||
// If the active mdi window is different from an Eclipse view, search through available mdi windows to find the
|
||||
// last activated Eclipse view. The sub windows are returned with the most recent activated window at the back.
|
||||
QList<QMdiSubWindow*> subWindows = RiuMainWindow::instance()->subWindowList( QMdiArea::ActivationHistoryOrder );
|
||||
for ( int i = subWindows.size() - 1; i > -1; i-- )
|
||||
{
|
||||
RiuViewer* viewer = subWindows[i]->widget()->findChild<RiuViewer*>();
|
||||
if (viewer)
|
||||
if ( viewer )
|
||||
{
|
||||
RimEclipseView* riv = dynamic_cast<RimEclipseView*>(viewer->ownerReservoirView());
|
||||
if (riv)
|
||||
RimEclipseView* riv = dynamic_cast<RimEclipseView*>( viewer->ownerReservoirView() );
|
||||
if ( riv )
|
||||
{
|
||||
return riv->eclipseCase();
|
||||
}
|
||||
@@ -169,17 +170,17 @@ RimEclipseCase* RiaSocketServer::findReservoir(int caseId)
|
||||
}
|
||||
else
|
||||
{
|
||||
RimProject* project = RiaApplication::instance()->project();
|
||||
if (!project) return nullptr;
|
||||
RimProject* project = RiaApplication::instance()->project();
|
||||
if ( !project ) return nullptr;
|
||||
|
||||
std::vector<RimCase*> cases;
|
||||
project->allCases(cases);
|
||||
project->allCases( cases );
|
||||
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
for ( size_t i = 0; i < cases.size(); i++ )
|
||||
{
|
||||
if (cases[i]->caseId == currCaseId)
|
||||
if ( cases[i]->caseId == currCaseId )
|
||||
{
|
||||
return dynamic_cast<RimEclipseCase*>(cases[i]);
|
||||
return dynamic_cast<RimEclipseCase*>( cases[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,73 +195,73 @@ RimEclipseCase* RiaSocketServer::findReservoir(int caseId)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaSocketServer::readCommandFromOctave()
|
||||
{
|
||||
QDataStream socketStream(m_currentClient);
|
||||
socketStream.setVersion(riOctavePlugin::qtDataStreamVersion);
|
||||
QDataStream socketStream( m_currentClient );
|
||||
socketStream.setVersion( riOctavePlugin::qtDataStreamVersion );
|
||||
|
||||
// If we have not read the currentCommandSize
|
||||
// read the size of the command if all the data is available
|
||||
|
||||
if (m_currentCommandSize == 0)
|
||||
if ( m_currentCommandSize == 0 )
|
||||
{
|
||||
if (m_currentClient->bytesAvailable() < (int)sizeof(qint64)) return false;
|
||||
if ( m_currentClient->bytesAvailable() < (int)sizeof( qint64 ) ) return false;
|
||||
|
||||
socketStream >> m_currentCommandSize;
|
||||
}
|
||||
|
||||
// Check if the complete command is available, return and whait for readyRead() if not
|
||||
if (m_currentClient->bytesAvailable() < m_currentCommandSize) return false;
|
||||
if ( m_currentClient->bytesAvailable() < m_currentCommandSize ) return false;
|
||||
|
||||
// Now we can read the command name
|
||||
|
||||
QByteArray command = m_currentClient->read( m_currentCommandSize);
|
||||
QTextStream commandStream(command);
|
||||
QByteArray command = m_currentClient->read( m_currentCommandSize );
|
||||
QTextStream commandStream( command );
|
||||
|
||||
QList<QByteArray> args;
|
||||
while (!commandStream.atEnd())
|
||||
while ( !commandStream.atEnd() )
|
||||
{
|
||||
QByteArray arg;
|
||||
commandStream >> arg;
|
||||
args.push_back(arg);
|
||||
args.push_back( arg );
|
||||
}
|
||||
|
||||
CVF_ASSERT(args.size() > 0);
|
||||
CVF_ASSERT( args.size() > 0 );
|
||||
|
||||
// Create the actual RiaSocketCommand object that will interpret the socket data
|
||||
|
||||
m_currentCommand = RiaSocketCommandFactory::instance()->create(args[0]);
|
||||
m_currentCommand = RiaSocketCommandFactory::instance()->create( args[0] );
|
||||
|
||||
if (m_currentCommand)
|
||||
if ( m_currentCommand )
|
||||
{
|
||||
bool finished = m_currentCommand->interpretCommand(this, args, socketStream);
|
||||
bool finished = m_currentCommand->interpretCommand( this, args, socketStream );
|
||||
return finished;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString txt;
|
||||
txt = QString("ResInsight SocketServer: Unknown command: %1").arg(args[0].data());
|
||||
txt = QString( "ResInsight SocketServer: Unknown command: %1" ).arg( args[0].data() );
|
||||
|
||||
RiaLogging::error(txt);
|
||||
RiaLogging::error( txt );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::slotCurrentClientDisconnected()
|
||||
{
|
||||
if (m_currentCommand)
|
||||
if ( m_currentCommand )
|
||||
{
|
||||
// Make sure we read what can be read.
|
||||
bool isFinished = m_currentCommand->interpretMore(this, m_currentClient);
|
||||
bool isFinished = m_currentCommand->interpretMore( this, m_currentClient );
|
||||
|
||||
if (!isFinished)
|
||||
if ( !isFinished )
|
||||
{
|
||||
QString txt;
|
||||
txt = QString("ResInsight SocketServer: The command was interrupted and did not finish because the connection to octave disconnected.");
|
||||
txt = QString( "ResInsight SocketServer: The command was interrupted and did not finish because the "
|
||||
"connection to octave disconnected." );
|
||||
|
||||
RiaLogging::error(txt);
|
||||
RiaLogging::error( txt );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,11 +273,11 @@ void RiaSocketServer::slotCurrentClientDisconnected()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::slotReadyRead()
|
||||
{
|
||||
if (m_currentCommand)
|
||||
if ( m_currentCommand )
|
||||
{
|
||||
bool isFinished = m_currentCommand->interpretMore(this, m_currentClient);
|
||||
bool isFinished = m_currentCommand->interpretMore( this, m_currentClient );
|
||||
|
||||
if (isFinished)
|
||||
if ( isFinished )
|
||||
{
|
||||
handleNextPendingConnection();
|
||||
}
|
||||
@@ -284,7 +285,7 @@ void RiaSocketServer::slotReadyRead()
|
||||
else
|
||||
{
|
||||
bool isFinished = readCommandFromOctave();
|
||||
if (isFinished)
|
||||
if ( isFinished )
|
||||
{
|
||||
handleNextPendingConnection();
|
||||
}
|
||||
@@ -292,15 +293,15 @@ void RiaSocketServer::slotReadyRead()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::setCurrentCaseId(int caseId)
|
||||
void RiaSocketServer::setCurrentCaseId( int caseId )
|
||||
{
|
||||
m_currentCaseId = caseId;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiaSocketServer::currentCaseId() const
|
||||
{
|
||||
@@ -310,9 +311,9 @@ int RiaSocketServer::currentCaseId() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::showErrorMessage(const QString& message) const
|
||||
void RiaSocketServer::showErrorMessage( const QString& message ) const
|
||||
{
|
||||
RiaLogging::error(message);
|
||||
RiaLogging::error( message );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -320,63 +321,62 @@ void RiaSocketServer::showErrorMessage(const QString& message) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::terminateCurrentConnection()
|
||||
{
|
||||
if (m_currentClient)
|
||||
if ( m_currentClient )
|
||||
{
|
||||
m_currentClient->disconnect(SIGNAL(disconnected()));
|
||||
m_currentClient->disconnect(SIGNAL(readyRead()));
|
||||
m_currentClient->disconnect( SIGNAL( disconnected() ) );
|
||||
m_currentClient->disconnect( SIGNAL( readyRead() ) );
|
||||
m_currentClient->deleteLater();
|
||||
m_currentClient = nullptr;
|
||||
}
|
||||
|
||||
// Clean up more state:
|
||||
|
||||
if (m_currentCommand)
|
||||
if ( m_currentCommand )
|
||||
{
|
||||
delete m_currentCommand;
|
||||
m_currentCommand = nullptr;
|
||||
}
|
||||
|
||||
m_currentCommandSize = 0;
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::handleNextPendingConnection()
|
||||
{
|
||||
if (m_currentClient && (m_currentClient->state() != QAbstractSocket::UnconnectedState) )
|
||||
if ( m_currentClient && ( m_currentClient->state() != QAbstractSocket::UnconnectedState ) )
|
||||
{
|
||||
//PMonLog("Starting Timer");
|
||||
// PMonLog("Starting Timer");
|
||||
m_nextPendingConnectionTimer->start(); // Reset and start again
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop timer
|
||||
if (m_nextPendingConnectionTimer->isActive())
|
||||
{
|
||||
//PMonLog("Stopping Timer");
|
||||
if ( m_nextPendingConnectionTimer->isActive() )
|
||||
{
|
||||
// PMonLog("Stopping Timer");
|
||||
m_nextPendingConnectionTimer->stop();
|
||||
}
|
||||
|
||||
terminateCurrentConnection();
|
||||
|
||||
QTcpSocket* clientToHandle = m_tcpServer->nextPendingConnection();
|
||||
if (clientToHandle)
|
||||
if ( clientToHandle )
|
||||
{
|
||||
CVF_ASSERT(m_currentClient == nullptr);
|
||||
CVF_ASSERT(m_currentCommand == nullptr);
|
||||
CVF_ASSERT( m_currentClient == nullptr );
|
||||
CVF_ASSERT( m_currentCommand == nullptr );
|
||||
|
||||
m_currentClient = clientToHandle;
|
||||
m_currentClient = clientToHandle;
|
||||
m_currentCommandSize = 0;
|
||||
|
||||
connect(m_currentClient, SIGNAL(disconnected()), this, SLOT(slotCurrentClientDisconnected()));
|
||||
connect(m_currentClient, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
|
||||
connect( m_currentClient, SIGNAL( disconnected() ), this, SLOT( slotCurrentClientDisconnected() ) );
|
||||
connect( m_currentClient, SIGNAL( readyRead() ), this, SLOT( slotReadyRead() ) );
|
||||
|
||||
if (m_currentClient->bytesAvailable())
|
||||
if ( m_currentClient->bytesAvailable() )
|
||||
{
|
||||
bool isFinished = this->readCommandFromOctave();
|
||||
if (isFinished)
|
||||
if ( isFinished )
|
||||
{
|
||||
// Call ourselves recursively until there are none left, or until it can not be processed in one go.
|
||||
this->handleNextPendingConnection();
|
||||
@@ -384,4 +384,3 @@ void RiaSocketServer::handleNextPendingConnection()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron AS
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
#include "RiaSocketServerDefines.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QObject>
|
||||
#include <vector>
|
||||
#include <QDataStream>
|
||||
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
@@ -43,40 +43,47 @@ class RiaSocketServer : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ReadState {ReadingCommand, ReadingPropertyData};
|
||||
enum ReadState
|
||||
{
|
||||
ReadingCommand,
|
||||
ReadingPropertyData
|
||||
};
|
||||
|
||||
public:
|
||||
explicit RiaSocketServer(QObject *parent = nullptr);
|
||||
explicit RiaSocketServer( QObject* parent = nullptr );
|
||||
~RiaSocketServer() override;
|
||||
|
||||
unsigned short serverPort();
|
||||
RimEclipseCase* findReservoir(int caseId);
|
||||
QTcpSocket* currentClient() { return m_currentClient; }
|
||||
unsigned short serverPort();
|
||||
RimEclipseCase* findReservoir( int caseId );
|
||||
QTcpSocket* currentClient()
|
||||
{
|
||||
return m_currentClient;
|
||||
}
|
||||
|
||||
void setCurrentCaseId(int caseId);
|
||||
int currentCaseId() const;
|
||||
void setCurrentCaseId( int caseId );
|
||||
int currentCaseId() const;
|
||||
|
||||
void showErrorMessage(const QString& message) const;
|
||||
void showErrorMessage( const QString& message ) const;
|
||||
|
||||
private slots:
|
||||
void slotNewClientConnection();
|
||||
void slotCurrentClientDisconnected();
|
||||
void slotReadyRead();
|
||||
void slotNewClientConnection();
|
||||
void slotCurrentClientDisconnected();
|
||||
void slotReadyRead();
|
||||
|
||||
private:
|
||||
void handleNextPendingConnection();
|
||||
void terminateCurrentConnection();
|
||||
bool readCommandFromOctave();
|
||||
void handleNextPendingConnection();
|
||||
void terminateCurrentConnection();
|
||||
bool readCommandFromOctave();
|
||||
|
||||
private:
|
||||
QTcpServer* m_tcpServer;
|
||||
QTcpServer* m_tcpServer;
|
||||
|
||||
QTcpSocket* m_currentClient;
|
||||
qint64 m_currentCommandSize; ///< The size in bytes of the command we are currently reading.
|
||||
QTcpSocket* m_currentClient;
|
||||
qint64 m_currentCommandSize; ///< The size in bytes of the command we are currently reading.
|
||||
|
||||
RiaSocketCommand* m_currentCommand;
|
||||
RiaSocketCommand* m_currentCommand;
|
||||
|
||||
QTimer* m_nextPendingConnectionTimer;
|
||||
QTimer* m_nextPendingConnectionTimer;
|
||||
|
||||
int m_currentCaseId; // Set to -1 to use default server behavior
|
||||
int m_currentCaseId; // Set to -1 to use default server behavior
|
||||
};
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -20,6 +20,5 @@
|
||||
|
||||
namespace riOctavePlugin
|
||||
{
|
||||
const int qtDataStreamVersion = QDataStream::Qt_4_0;
|
||||
const int qtDataStreamVersion = QDataStream::Qt_4_0;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron AS
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -44,51 +44,52 @@
|
||||
#include <QTcpSocket>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseCase* RiaSocketTools::findCaseFromArgs(RiaSocketServer* server, const QList<QByteArray>& args)
|
||||
RimEclipseCase* RiaSocketTools::findCaseFromArgs( RiaSocketServer* server, const QList<QByteArray>& args )
|
||||
{
|
||||
RimEclipseCase* rimCase = nullptr;
|
||||
int caseId = -1;
|
||||
int caseId = -1;
|
||||
|
||||
if (args.size() > 1)
|
||||
if ( args.size() > 1 )
|
||||
{
|
||||
caseId = args[1].toInt();
|
||||
}
|
||||
rimCase = server->findReservoir(caseId);
|
||||
rimCase = server->findReservoir( caseId );
|
||||
|
||||
if (rimCase == nullptr)
|
||||
if ( rimCase == nullptr )
|
||||
{
|
||||
// TODO: Display error message a different place to avoid socket comm to be halted.
|
||||
//server->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the Case with CaseId : \"%1\"").arg(caseId));
|
||||
// server->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find
|
||||
// the Case with CaseId : \"%1\"").arg(caseId));
|
||||
}
|
||||
|
||||
return rimCase;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketTools::getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId)
|
||||
void RiaSocketTools::getCaseInfoFromCase(
|
||||
RimCase* rimCase, qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId )
|
||||
{
|
||||
CVF_ASSERT(rimCase);
|
||||
CVF_ASSERT( rimCase );
|
||||
|
||||
caseId = rimCase->caseId;
|
||||
caseId = rimCase->caseId;
|
||||
caseName = rimCase->caseUserDescription;
|
||||
|
||||
RimEclipseCase* eclCase = dynamic_cast<RimEclipseCase*> (rimCase);
|
||||
RimEclipseCase* eclCase = dynamic_cast<RimEclipseCase*>( rimCase );
|
||||
RimCaseCollection* caseCollection = nullptr;
|
||||
if (eclCase)
|
||||
if ( eclCase )
|
||||
{
|
||||
caseCollection = eclCase->parentCaseCollection();
|
||||
}
|
||||
|
||||
if (caseCollection)
|
||||
if ( caseCollection )
|
||||
{
|
||||
caseGroupId = caseCollection->parentCaseGroup()->groupId;
|
||||
|
||||
if (RimIdenticalGridCaseGroup::isStatisticsCaseCollection(caseCollection))
|
||||
if ( RimIdenticalGridCaseGroup::isStatisticsCaseCollection( caseCollection ) )
|
||||
{
|
||||
caseType = "StatisticsCase";
|
||||
}
|
||||
@@ -101,11 +102,11 @@ void RiaSocketTools::getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QStri
|
||||
{
|
||||
caseGroupId = -1;
|
||||
|
||||
if (dynamic_cast<RimEclipseInputCase*>(rimCase))
|
||||
if ( dynamic_cast<RimEclipseInputCase*>( rimCase ) )
|
||||
{
|
||||
caseType = "InputCase";
|
||||
}
|
||||
else if (eclCase)
|
||||
else if ( eclCase )
|
||||
{
|
||||
caseType = "ResultCase";
|
||||
}
|
||||
@@ -117,20 +118,20 @@ void RiaSocketTools::getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QStri
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaSocketTools::writeBlockData(RiaSocketServer* server, QTcpSocket* socket, const char* data, quint64 bytesToWrite)
|
||||
bool RiaSocketTools::writeBlockData( RiaSocketServer* server, QTcpSocket* socket, const char* data, quint64 bytesToWrite )
|
||||
{
|
||||
cvf::Timer timer;
|
||||
|
||||
QStringList errorMessages;
|
||||
bool writeSucceded = RiaSocketDataTransfer::writeBlockDataToSocket(socket, data, bytesToWrite, errorMessages);
|
||||
bool writeSucceded = RiaSocketDataTransfer::writeBlockDataToSocket( socket, data, bytesToWrite, errorMessages );
|
||||
|
||||
if (server)
|
||||
if ( server )
|
||||
{
|
||||
for (int i = 0; i < errorMessages.size(); i++)
|
||||
for ( int i = 0; i < errorMessages.size(); i++ )
|
||||
{
|
||||
server->showErrorMessage(errorMessages[i]);
|
||||
server->showErrorMessage( errorMessages[i] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron AS
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -25,16 +25,17 @@ class RiaSocketServer;
|
||||
class RimEclipseCase;
|
||||
class QTcpSocket;
|
||||
|
||||
#include <QList>
|
||||
#include <QByteArray>
|
||||
#include <QList>
|
||||
|
||||
#define PMonLog( MessageString ) RiuMainWindow::instance()->processMonitor()->addStringToLog( MessageString );
|
||||
|
||||
class RiaSocketTools
|
||||
{
|
||||
public:
|
||||
static RimEclipseCase* findCaseFromArgs(RiaSocketServer* server, const QList<QByteArray>& args);
|
||||
static void getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId);
|
||||
|
||||
static bool writeBlockData(RiaSocketServer* server, QTcpSocket* socket, const char* data, quint64 bytesToWrite);
|
||||
static RimEclipseCase* findCaseFromArgs( RiaSocketServer* server, const QList<QByteArray>& args );
|
||||
static void
|
||||
getCaseInfoFromCase( RimCase* rimCase, qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId );
|
||||
|
||||
static bool writeBlockData( RiaSocketServer* server, QTcpSocket* socket, const char* data, quint64 bytesToWrite );
|
||||
};
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron AS
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -22,8 +22,8 @@
|
||||
#include "RiaSocketServer.h"
|
||||
#include "RiaSocketTools.h"
|
||||
|
||||
#include "RigGridBase.h"
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigGridBase.h"
|
||||
#include "RigSimWellData.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
@@ -32,22 +32,25 @@
|
||||
|
||||
#include <QTcpSocket>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetWellNames : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetWellNames"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
RimEclipseCase* rimCase = server->findReservoir(caseId);
|
||||
if (!rimCase)
|
||||
return QString( "GetWellNames" );
|
||||
}
|
||||
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
RimEclipseCase* rimCase = server->findReservoir( caseId );
|
||||
if ( !rimCase )
|
||||
{
|
||||
server->showErrorMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID : \"%1\"").arg(caseId));
|
||||
server->showErrorMessage( RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr( "Could not find the case with ID : \"%1\"" ).arg( caseId ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -55,24 +58,24 @@ public:
|
||||
std::vector<QString> wellNames;
|
||||
|
||||
const cvf::Collection<RigSimWellData>& wells = rimCase->eclipseCaseData()->wellResults();
|
||||
|
||||
for (size_t wIdx = 0; wIdx < wells.size(); ++wIdx)
|
||||
|
||||
for ( size_t wIdx = 0; wIdx < wells.size(); ++wIdx )
|
||||
{
|
||||
wellNames.push_back(wells[wIdx]->m_wellName);
|
||||
wellNames.push_back( wells[wIdx]->m_wellName );
|
||||
}
|
||||
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
quint64 byteCount = sizeof( quint64 );
|
||||
quint64 wellCount = wellNames.size();
|
||||
|
||||
for (size_t wIdx = 0; wIdx < wellCount; wIdx++)
|
||||
for ( size_t wIdx = 0; wIdx < wellCount; wIdx++ )
|
||||
{
|
||||
byteCount += wellNames[wIdx].size() * sizeof(QChar);
|
||||
byteCount += wellNames[wIdx].size() * sizeof( QChar );
|
||||
}
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << wellCount;
|
||||
|
||||
for (size_t wIdx = 0; wIdx < wellCount; wIdx++)
|
||||
for ( size_t wIdx = 0; wIdx < wellCount; wIdx++ )
|
||||
{
|
||||
socketStream << wellNames[wIdx];
|
||||
}
|
||||
@@ -81,9 +84,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetWellNames_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetWellNames>(RiaGetWellNames::commandName());
|
||||
|
||||
|
||||
static bool RiaGetWellNames_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetWellNames>(
|
||||
RiaGetWellNames::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -91,17 +93,21 @@ static bool RiaGetWellNames_init = RiaSocketCommandFactory::instance()->register
|
||||
class RiaGetWellStatus : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetWellStatus"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
QString wellName = args[2];
|
||||
return QString( "GetWellStatus" );
|
||||
}
|
||||
|
||||
RimEclipseCase* rimCase = server->findReservoir(caseId);
|
||||
if (!rimCase)
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
QString wellName = args[2];
|
||||
|
||||
RimEclipseCase* rimCase = server->findReservoir( caseId );
|
||||
if ( !rimCase )
|
||||
{
|
||||
server->showErrorMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID : \"%1\"").arg(caseId));
|
||||
server->showErrorMessage( RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr( "Could not find the case with ID : \"%1\"" ).arg( caseId ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -109,48 +115,48 @@ public:
|
||||
// Create a list of all the requested time steps
|
||||
|
||||
std::vector<size_t> requestedTimesteps;
|
||||
//First find the well result for the correct well
|
||||
// First find the well result for the correct well
|
||||
|
||||
const cvf::Collection<RigSimWellData>& allWellRes = rimCase->eclipseCaseData()->wellResults();
|
||||
cvf::ref<RigSimWellData> currentWellResult;
|
||||
for (size_t tsIdx = 0; tsIdx < allWellRes.size(); ++tsIdx)
|
||||
const cvf::Collection<RigSimWellData>& allWellRes = rimCase->eclipseCaseData()->wellResults();
|
||||
cvf::ref<RigSimWellData> currentWellResult;
|
||||
for ( size_t tsIdx = 0; tsIdx < allWellRes.size(); ++tsIdx )
|
||||
{
|
||||
if (allWellRes[tsIdx]->m_wellName == wellName)
|
||||
if ( allWellRes[tsIdx]->m_wellName == wellName )
|
||||
{
|
||||
currentWellResult = allWellRes[tsIdx];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentWellResult.isNull())
|
||||
if ( currentWellResult.isNull() )
|
||||
{
|
||||
server->showErrorMessage(
|
||||
RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the well with name : \"%1\"").arg(wellName));
|
||||
RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr( "Could not find the well with name : \"%1\"" ).arg( wellName ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (args.size() <= 3)
|
||||
if ( args.size() <= 3 )
|
||||
{
|
||||
// Select all timesteps.
|
||||
// Select all timesteps.
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < currentWellResult->m_resultTimeStepIndexToWellTimeStepIndex.size(); ++tsIdx)
|
||||
for ( size_t tsIdx = 0; tsIdx < currentWellResult->m_resultTimeStepIndexToWellTimeStepIndex.size(); ++tsIdx )
|
||||
{
|
||||
requestedTimesteps.push_back(tsIdx);
|
||||
requestedTimesteps.push_back( tsIdx );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool timeStepReadError = false;
|
||||
for (int argIdx = 3; argIdx < args.size(); ++argIdx)
|
||||
for ( int argIdx = 3; argIdx < args.size(); ++argIdx )
|
||||
{
|
||||
bool conversionOk = false;
|
||||
int tsIdx = args[argIdx].toInt(&conversionOk);
|
||||
int tsIdx = args[argIdx].toInt( &conversionOk );
|
||||
|
||||
if (conversionOk)
|
||||
if ( conversionOk )
|
||||
{
|
||||
requestedTimesteps.push_back(tsIdx);
|
||||
requestedTimesteps.push_back( tsIdx );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -158,58 +164,59 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (timeStepReadError)
|
||||
if ( timeStepReadError )
|
||||
{
|
||||
server->showErrorMessage(RiaSocketServer::tr("ResInsight SocketServer: riGetGridProperty : \n")
|
||||
+ RiaSocketServer::tr("An error occured while interpreting the requested timesteps."));
|
||||
server->showErrorMessage(
|
||||
RiaSocketServer::tr( "ResInsight SocketServer: riGetGridProperty : \n" ) +
|
||||
RiaSocketServer::tr( "An error occured while interpreting the requested timesteps." ) );
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<QString> wellTypes;
|
||||
std::vector<qint32> wellStatuses;
|
||||
std::vector<qint32> wellStatuses;
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < requestedTimesteps.size(); ++tsIdx)
|
||||
for ( size_t tsIdx = 0; tsIdx < requestedTimesteps.size(); ++tsIdx )
|
||||
{
|
||||
QString wellType = "NotDefined";
|
||||
qint32 wellStatus = 0;
|
||||
if (currentWellResult->hasWellResult(tsIdx))
|
||||
QString wellType = "NotDefined";
|
||||
qint32 wellStatus = 0;
|
||||
if ( currentWellResult->hasWellResult( tsIdx ) )
|
||||
{
|
||||
switch(currentWellResult->wellResultFrame(tsIdx).m_productionType)
|
||||
switch ( currentWellResult->wellResultFrame( tsIdx ).m_productionType )
|
||||
{
|
||||
case RigWellResultFrame::PRODUCER:
|
||||
wellType = "Producer";
|
||||
break;
|
||||
case RigWellResultFrame::OIL_INJECTOR:
|
||||
wellType = "OilInjector";
|
||||
break;
|
||||
case RigWellResultFrame::WATER_INJECTOR:
|
||||
wellType = "WaterInjector";
|
||||
break;
|
||||
case RigWellResultFrame::GAS_INJECTOR:
|
||||
wellType = "GasInjector";
|
||||
break;
|
||||
case RigWellResultFrame::PRODUCER:
|
||||
wellType = "Producer";
|
||||
break;
|
||||
case RigWellResultFrame::OIL_INJECTOR:
|
||||
wellType = "OilInjector";
|
||||
break;
|
||||
case RigWellResultFrame::WATER_INJECTOR:
|
||||
wellType = "WaterInjector";
|
||||
break;
|
||||
case RigWellResultFrame::GAS_INJECTOR:
|
||||
wellType = "GasInjector";
|
||||
break;
|
||||
}
|
||||
|
||||
wellStatus = currentWellResult->wellResultFrame(tsIdx).m_isOpen ? 1 : 0;
|
||||
wellStatus = currentWellResult->wellResultFrame( tsIdx ).m_isOpen ? 1 : 0;
|
||||
}
|
||||
|
||||
wellTypes.push_back(wellType);
|
||||
wellStatuses.push_back(wellStatus);
|
||||
wellTypes.push_back( wellType );
|
||||
wellStatuses.push_back( wellStatus );
|
||||
}
|
||||
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
quint64 byteCount = sizeof( quint64 );
|
||||
quint64 timeStepCount = wellTypes.size();
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < timeStepCount; tsIdx++)
|
||||
for ( size_t tsIdx = 0; tsIdx < timeStepCount; tsIdx++ )
|
||||
{
|
||||
byteCount += wellTypes[tsIdx].size() * sizeof(QChar);
|
||||
byteCount += sizeof(qint32);
|
||||
byteCount += wellTypes[tsIdx].size() * sizeof( QChar );
|
||||
byteCount += sizeof( qint32 );
|
||||
}
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << timeStepCount;
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < timeStepCount; tsIdx++)
|
||||
for ( size_t tsIdx = 0; tsIdx < timeStepCount; tsIdx++ )
|
||||
{
|
||||
socketStream << wellTypes[tsIdx];
|
||||
socketStream << wellStatuses[tsIdx];
|
||||
@@ -219,9 +226,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetWellStatus_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetWellStatus>(RiaGetWellStatus::commandName());
|
||||
|
||||
|
||||
static bool RiaGetWellStatus_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetWellStatus>(
|
||||
RiaGetWellStatus::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -229,51 +235,56 @@ static bool RiaGetWellStatus_init = RiaSocketCommandFactory::instance()->registe
|
||||
class RiaGetWellCells : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetWellCells"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
QString wellName = args[2];
|
||||
size_t timeStepIdx = args[3].toInt() - 1; // Interpret timeStepIdx from octave as 1-based
|
||||
return QString( "GetWellCells" );
|
||||
}
|
||||
|
||||
RimEclipseCase* rimCase = server->findReservoir(caseId);
|
||||
if (!rimCase)
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
QString wellName = args[2];
|
||||
size_t timeStepIdx = args[3].toInt() - 1; // Interpret timeStepIdx from octave as 1-based
|
||||
|
||||
RimEclipseCase* rimCase = server->findReservoir( caseId );
|
||||
if ( !rimCase )
|
||||
{
|
||||
server->showErrorMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID : \"%1\"").arg(caseId));
|
||||
server->showErrorMessage( RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr( "Could not find the case with ID : \"%1\"" ).arg( caseId ) );
|
||||
|
||||
socketStream << (quint64)0;
|
||||
return true;
|
||||
}
|
||||
|
||||
const cvf::Collection<RigSimWellData>& allWellRes = rimCase->eclipseCaseData()->wellResults();
|
||||
cvf::ref<RigSimWellData> currentWellResult;
|
||||
for (size_t cIdx = 0; cIdx < allWellRes.size(); ++cIdx)
|
||||
|
||||
const cvf::Collection<RigSimWellData>& allWellRes = rimCase->eclipseCaseData()->wellResults();
|
||||
cvf::ref<RigSimWellData> currentWellResult;
|
||||
for ( size_t cIdx = 0; cIdx < allWellRes.size(); ++cIdx )
|
||||
{
|
||||
if (allWellRes[cIdx]->m_wellName == wellName)
|
||||
if ( allWellRes[cIdx]->m_wellName == wellName )
|
||||
{
|
||||
currentWellResult = allWellRes[cIdx];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentWellResult.isNull())
|
||||
if ( currentWellResult.isNull() )
|
||||
{
|
||||
server->showErrorMessage(
|
||||
RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the well with name : \"%1\"").arg(wellName));
|
||||
RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr( "Could not find the well with name : \"%1\"" ).arg( wellName ) );
|
||||
|
||||
socketStream << (quint64)0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!currentWellResult->hasWellResult(timeStepIdx))
|
||||
if ( !currentWellResult->hasWellResult( timeStepIdx ) )
|
||||
{
|
||||
socketStream << (quint64)0;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<qint32> cellIs;
|
||||
std::vector<qint32> cellJs;
|
||||
std::vector<qint32> cellIs;
|
||||
std::vector<qint32> cellJs;
|
||||
std::vector<qint32> cellKs;
|
||||
std::vector<qint32> gridIndices;
|
||||
std::vector<qint32> cellStatuses;
|
||||
@@ -281,51 +292,52 @@ public:
|
||||
std::vector<qint32> segmentIds;
|
||||
|
||||
// Fetch results
|
||||
const RigWellResultFrame& wellResFrame = currentWellResult->wellResultFrame(timeStepIdx);
|
||||
const RigWellResultFrame& wellResFrame = currentWellResult->wellResultFrame( timeStepIdx );
|
||||
std::vector<RigGridBase*> grids;
|
||||
rimCase->eclipseCaseData()->allGrids(&grids);
|
||||
rimCase->eclipseCaseData()->allGrids( &grids );
|
||||
|
||||
for (size_t bIdx = 0; bIdx < wellResFrame.m_wellResultBranches.size(); ++bIdx)
|
||||
for ( size_t bIdx = 0; bIdx < wellResFrame.m_wellResultBranches.size(); ++bIdx )
|
||||
{
|
||||
const std::vector<RigWellResultPoint>& branchResPoints = wellResFrame.m_wellResultBranches[bIdx].m_branchResultPoints;
|
||||
for (size_t rpIdx = 0; rpIdx < branchResPoints.size(); ++rpIdx)
|
||||
const std::vector<RigWellResultPoint>& branchResPoints = wellResFrame.m_wellResultBranches[bIdx]
|
||||
.m_branchResultPoints;
|
||||
for ( size_t rpIdx = 0; rpIdx < branchResPoints.size(); ++rpIdx )
|
||||
{
|
||||
const RigWellResultPoint& resPoint = branchResPoints[rpIdx];
|
||||
|
||||
if (resPoint.isCell())
|
||||
if ( resPoint.isCell() )
|
||||
{
|
||||
size_t i;
|
||||
size_t i;
|
||||
size_t j;
|
||||
size_t k;
|
||||
size_t gridIdx = resPoint.m_gridIndex ;
|
||||
grids[gridIdx]->ijkFromCellIndex(resPoint.m_gridCellIndex, &i, &j, &k);
|
||||
size_t gridIdx = resPoint.m_gridIndex;
|
||||
grids[gridIdx]->ijkFromCellIndex( resPoint.m_gridCellIndex, &i, &j, &k );
|
||||
bool isOpen = resPoint.m_isOpen;
|
||||
int branchId = resPoint.m_ertBranchId;
|
||||
int segmentId = resPoint.m_ertSegmentId;
|
||||
int branchId = resPoint.m_ertBranchId;
|
||||
int segmentId = resPoint.m_ertSegmentId;
|
||||
|
||||
cellIs .push_back( static_cast<qint32>(i + 1) ); // NB: 1-based index in Octave
|
||||
cellJs .push_back( static_cast<qint32>(j + 1) ); // NB: 1-based index in Octave
|
||||
cellKs .push_back( static_cast<qint32>(k + 1) ); // NB: 1-based index in Octave
|
||||
gridIndices .push_back( static_cast<qint32>(gridIdx) );
|
||||
cellStatuses.push_back( static_cast<qint32>(isOpen) );
|
||||
branchIds .push_back( branchId );
|
||||
segmentIds .push_back( segmentId);
|
||||
cellIs.push_back( static_cast<qint32>( i + 1 ) ); // NB: 1-based index in Octave
|
||||
cellJs.push_back( static_cast<qint32>( j + 1 ) ); // NB: 1-based index in Octave
|
||||
cellKs.push_back( static_cast<qint32>( k + 1 ) ); // NB: 1-based index in Octave
|
||||
gridIndices.push_back( static_cast<qint32>( gridIdx ) );
|
||||
cellStatuses.push_back( static_cast<qint32>( isOpen ) );
|
||||
branchIds.push_back( branchId );
|
||||
segmentIds.push_back( segmentId );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
quint64 byteCount = sizeof( quint64 );
|
||||
quint64 cellCount = cellIs.size();
|
||||
|
||||
byteCount += cellCount*( 7 * sizeof(qint32));
|
||||
byteCount += cellCount * ( 7 * sizeof( qint32 ) );
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << cellCount;
|
||||
|
||||
for (size_t cIdx = 0; cIdx < cellCount; cIdx++)
|
||||
for ( size_t cIdx = 0; cIdx < cellCount; cIdx++ )
|
||||
{
|
||||
socketStream << cellIs[cIdx];
|
||||
socketStream << cellJs[cIdx];
|
||||
socketStream << cellIs[cIdx];
|
||||
socketStream << cellJs[cIdx];
|
||||
socketStream << cellKs[cIdx];
|
||||
socketStream << gridIndices[cIdx];
|
||||
socketStream << cellStatuses[cIdx];
|
||||
@@ -337,4 +349,5 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetWellCells_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetWellCells>(RiaGetWellCells::commandName());
|
||||
static bool RiaGetWellCells_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetWellCells>(
|
||||
RiaGetWellCells::commandName() );
|
||||
|
||||
Reference in New Issue
Block a user