mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Write all double values in one go. Fixed argument parsing.
p4#: 21746
This commit is contained in:
parent
83d5143b69
commit
1cfdb0ddb1
@ -20,11 +20,25 @@
|
|||||||
#include "RiaSocketServer.h"
|
#include "RiaSocketServer.h"
|
||||||
#include "RiaSocketTools.h"
|
#include "RiaSocketTools.h"
|
||||||
|
|
||||||
#include "RimCase.h"
|
#include "RiuMainWindow.h"
|
||||||
|
|
||||||
#include "RigCaseData.h"
|
#include "RigCaseData.h"
|
||||||
#include "RigCaseCellResultsData.h"
|
#include "RigCaseCellResultsData.h"
|
||||||
|
|
||||||
#include "RimReservoirCellResultsCacher.h"
|
#include "RimReservoirCellResultsCacher.h"
|
||||||
|
#include "RimCase.h"
|
||||||
|
#include "RimInputCase.h"
|
||||||
|
#include "RimInputPropertyCollection.h"
|
||||||
|
#include "RimUiTreeModelPdm.h"
|
||||||
|
#include "RimReservoirView.h"
|
||||||
|
#include "RimResultSlot.h"
|
||||||
|
#include "RimCellEdgeResultSlot.h"
|
||||||
|
#include "RimCellRangeFilterCollection.h"
|
||||||
|
#include "RimCellPropertyFilterCollection.h"
|
||||||
|
#include "RimWellCollection.h"
|
||||||
|
#include "Rim3dOverlayInfoConfig.h"
|
||||||
|
|
||||||
|
#include <QTcpSocket>
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -189,14 +203,21 @@ public:
|
|||||||
|
|
||||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||||
{
|
{
|
||||||
|
int caseId = args[1].toInt();
|
||||||
RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
int gridIdx = args[2].toInt();
|
||||||
|
QString propertyName = args[3];
|
||||||
int gridIdx = args[2].toInt();
|
|
||||||
|
|
||||||
QString propertyName = args[3];
|
|
||||||
QString porosityModelName = args[4];
|
QString porosityModelName = args[4];
|
||||||
|
|
||||||
|
RimCase*rimCase = server->findReservoir(caseId);
|
||||||
|
if (rimCase == NULL)
|
||||||
|
{
|
||||||
|
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID: \"%1\"").arg(caseId));
|
||||||
|
|
||||||
|
// No data available
|
||||||
|
socketStream << (quint64)0 << (quint64)0 << (quint64)0 << (quint64)0 ;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
RifReaderInterface::PorosityModelResultType porosityModelEnum = RifReaderInterface::MATRIX_RESULTS;
|
RifReaderInterface::PorosityModelResultType porosityModelEnum = RifReaderInterface::MATRIX_RESULTS;
|
||||||
if (porosityModelName == "Fracture")
|
if (porosityModelName == "Fracture")
|
||||||
{
|
{
|
||||||
@ -237,11 +258,11 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a list of all the requested timesteps
|
// Create a list of all the requested time steps
|
||||||
|
|
||||||
std::vector<size_t> requestedTimesteps;
|
std::vector<size_t> requestedTimesteps;
|
||||||
|
|
||||||
if (args.size() <= 4)
|
if (args.size() <= 5)
|
||||||
{
|
{
|
||||||
// Select all
|
// Select all
|
||||||
for (size_t tsIdx = 0; tsIdx < scalarResultFrames->size(); ++tsIdx)
|
for (size_t tsIdx = 0; tsIdx < scalarResultFrames->size(); ++tsIdx)
|
||||||
@ -252,7 +273,7 @@ public:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool timeStepReadError = false;
|
bool timeStepReadError = false;
|
||||||
for (int argIdx = 4; argIdx < args.size(); ++argIdx)
|
for (int argIdx = 5; argIdx < args.size(); ++argIdx)
|
||||||
{
|
{
|
||||||
bool conversionOk = false;
|
bool conversionOk = false;
|
||||||
int tsIdx = args[argIdx].toInt(&conversionOk);
|
int tsIdx = args[argIdx].toInt(&conversionOk);
|
||||||
@ -287,11 +308,15 @@ public:
|
|||||||
socketStream << cellCountJ;
|
socketStream << cellCountJ;
|
||||||
socketStream << cellCountK;
|
socketStream << cellCountK;
|
||||||
|
|
||||||
// Write timestep count
|
// Write time step count
|
||||||
|
|
||||||
quint64 timestepCount = (quint64)requestedTimesteps.size();
|
quint64 timestepCount = (quint64)requestedTimesteps.size();
|
||||||
socketStream << timestepCount;
|
socketStream << timestepCount;
|
||||||
|
|
||||||
|
size_t doubleValueCount = cellCountI * cellCountJ * cellCountK * timestepCount * sizeof(double);
|
||||||
|
std::vector<double> values(doubleValueCount);
|
||||||
|
size_t valueIdx = 0;
|
||||||
|
|
||||||
for (size_t tsIdx = 0; tsIdx < timestepCount; tsIdx++)
|
for (size_t tsIdx = 0; tsIdx < timestepCount; tsIdx++)
|
||||||
{
|
{
|
||||||
for (size_t k = 0; k < cellCountK; k++)
|
for (size_t k = 0; k < cellCountK; k++)
|
||||||
@ -307,17 +332,19 @@ public:
|
|||||||
|
|
||||||
if (resultIdx < scalarResultFrames->at(requestedTimesteps[tsIdx]).size())
|
if (resultIdx < scalarResultFrames->at(requestedTimesteps[tsIdx]).size())
|
||||||
{
|
{
|
||||||
socketStream << scalarResultFrames->at(requestedTimesteps[tsIdx])[resultIdx];
|
values[valueIdx++] = scalarResultFrames->at(requestedTimesteps[tsIdx])[resultIdx];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
socketStream << HUGE_VAL;
|
values[valueIdx++] = HUGE_VAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server->currentClient()->write((const char *)values.data(), doubleValueCount);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -327,27 +354,11 @@ static bool RiaGetGridProperty_init = RiaSocketCommandFactory::instance()->regis
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <QTcpSocket>
|
|
||||||
#include "RiuMainWindow.h"
|
|
||||||
#include "RimInputCase.h"
|
|
||||||
#include "RimInputPropertyCollection.h"
|
|
||||||
|
|
||||||
#include "RimUiTreeModelPdm.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include "RimReservoirView.h"
|
|
||||||
#include "RimResultSlot.h"
|
|
||||||
#include "RimCellEdgeResultSlot.h"
|
|
||||||
#include "RimCellRangeFilterCollection.h"
|
|
||||||
#include "RimCellPropertyFilterCollection.h"
|
|
||||||
#include "RimWellCollection.h"
|
|
||||||
#include "Rim3dOverlayInfoConfig.h"
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
class RiaSetActiveCellProperty: public RiaSocketCommand
|
class RiaSetActiveCellProperty: public RiaSocketCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -122,10 +122,10 @@ DEFUN_DLD (riGetGridProperty, args, nargout,
|
|||||||
"\n"
|
"\n"
|
||||||
"Matrix[numI][numJ][numK][numTimestepsRequested] riGetGridProperty([CaseId], GridIndex , PropertyName, [RequestedTimeSteps], [PorosityModel = \"Matrix\"|\"Fracture\"])"
|
"Matrix[numI][numJ][numK][numTimestepsRequested] riGetGridProperty([CaseId], GridIndex , PropertyName, [RequestedTimeSteps], [PorosityModel = \"Matrix\"|\"Fracture\"])"
|
||||||
"\n"
|
"\n"
|
||||||
"This function returns a matrix of the requested property data for all the grid cells in the requested grid for each requested time step."
|
"This function returns a matrix of the requested property data for all the grid cells in the requested grid for each requested time step.\n"
|
||||||
"Grids are indexed from 0 (main grid) to max number of LGR's"
|
"Grids are indexed from 0 (main grid) to max number of LGR's.\n"
|
||||||
"If the CaseId is not defined, ResInsight’s Current Case is used."
|
"If the CaseId is not defined, ResInsight’s Current Case is used.\n"
|
||||||
"The RequestedTimeSteps must contain a list of indices to the requested time steps. If not defined, all the time steps are returned"
|
"The RequestedTimeSteps must contain a list of indices to the requested time steps. If not defined, all the time steps are returned.\n"
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (nargout < 1)
|
if (nargout < 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user