mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Updated riGetGridProperty
This commit is contained in:
parent
34e6d98c76
commit
770f706803
@ -306,34 +306,6 @@ public:
|
|||||||
quint64 timestepCount = (quint64)requestedTimesteps.size();
|
quint64 timestepCount = (quint64)requestedTimesteps.size();
|
||||||
socketStream << timestepCount;
|
socketStream << timestepCount;
|
||||||
|
|
||||||
size_t valueIdx = 0;
|
|
||||||
cvf::Timer timer;
|
|
||||||
|
|
||||||
if (RiaApplication::instance()->preferences()->useStreamTransfer())
|
|
||||||
{
|
|
||||||
for (size_t tsIdx = 0; tsIdx < timestepCount; tsIdx++)
|
|
||||||
{
|
|
||||||
cvf::ref<cvf::StructGridScalarDataAccess> cellCenterDataAccessObject = rimCase->reservoirData()->dataAccessObject(rigGrid, porosityModelEnum, requestedTimesteps[tsIdx], scalarResultIndex);
|
|
||||||
if (cellCenterDataAccessObject.isNull())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t cellIdx = 0; cellIdx < rigGrid->cellCount(); cellIdx++)
|
|
||||||
{
|
|
||||||
double cellValue = cellCenterDataAccessObject->cellScalar(cellIdx);
|
|
||||||
if (cellValue == HUGE_VAL)
|
|
||||||
{
|
|
||||||
cellValue = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
socketStream << cellValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
for (size_t tsIdx = 0; tsIdx < timestepCount; tsIdx++)
|
for (size_t tsIdx = 0; tsIdx < timestepCount; tsIdx++)
|
||||||
{
|
{
|
||||||
cvf::ref<cvf::StructGridScalarDataAccess> cellCenterDataAccessObject = rimCase->reservoirData()->dataAccessObject(rigGrid, porosityModelEnum, requestedTimesteps[tsIdx], scalarResultIndex);
|
cvf::ref<cvf::StructGridScalarDataAccess> cellCenterDataAccessObject = rimCase->reservoirData()->dataAccessObject(rigGrid, porosityModelEnum, requestedTimesteps[tsIdx], scalarResultIndex);
|
||||||
@ -350,16 +322,11 @@ public:
|
|||||||
{
|
{
|
||||||
cellValue = 0.0;
|
cellValue = 0.0;
|
||||||
}
|
}
|
||||||
values[valueIdx++] = cellValue;
|
values[cellIdx] = cellValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)values.data(), values.size() * sizeof(double));
|
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)values.data(), values.size() * sizeof(double));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
double totalTimeMS = timer.time() * 1000.0;
|
|
||||||
QString resultInfo = QString("Total time '%1 ms'").arg(totalTimeMS);
|
|
||||||
|
|
||||||
server->errorMessageDialog()->showMessage(resultInfo);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
#include <QtNetwork>
|
#include <QtNetwork>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include <octave/oct.h>
|
#include <octave/oct.h>
|
||||||
|
|
||||||
#include "riSettings.h"
|
#include "riSettings.h"
|
||||||
|
#include "riSocketTools.h"
|
||||||
|
|
||||||
|
|
||||||
void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16 serverPort,
|
void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16 serverPort,
|
||||||
const int& caseId, int gridIdx, QString propertyName, const int32NDArray& requestedTimeSteps, QString porosityModel)
|
const int& caseId, int gridIdx, QString propertyName, const int32NDArray& requestedTimeSteps, QString porosityModel)
|
||||||
@ -61,8 +66,6 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
|
|||||||
|
|
||||||
totalByteCount = cellCountI*cellCountJ*cellCountK*timestepCount*sizeof(double);
|
totalByteCount = cellCountI*cellCountJ*cellCountK*timestepCount*sizeof(double);
|
||||||
|
|
||||||
qint64 timestepByteCount = cellCountI*cellCountJ*cellCountK*sizeof(double);
|
|
||||||
|
|
||||||
if (!(totalByteCount))
|
if (!(totalByteCount))
|
||||||
{
|
{
|
||||||
error ("Could not find the requested data in ResInsight");
|
error ("Could not find the requested data in ResInsight");
|
||||||
@ -78,93 +81,18 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
|
|||||||
|
|
||||||
propertyFrames.resize(dv);
|
propertyFrames.resize(dv);
|
||||||
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
// Wait for available data for each timestep, then read data for each timestep
|
|
||||||
|
|
||||||
qint64 totalBytesRead = 0;
|
|
||||||
|
|
||||||
for (size_t tIdx = 0; tIdx < timestepCount; ++tIdx)
|
|
||||||
{
|
|
||||||
qint64 bytesAvailable = socket.bytesAvailable() ;
|
|
||||||
|
|
||||||
while ( bytesAvailable < (qint64)timestepByteCount)
|
|
||||||
{
|
|
||||||
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
|
|
||||||
{
|
|
||||||
error((("Waiting for timestep data number: ") + QString::number(tIdx)+ ": " + socket.errorString()).toLatin1().data());
|
|
||||||
octave_stdout << "Cellcount: " << cellCountI*cellCountJ*cellCountK << ", Timesteps: " << timestepCount << std::endl;
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
bytesAvailable = socket.bytesAvailable();
|
|
||||||
|
|
||||||
OCTAVE_QUIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
qint64 bytesRead = 0;
|
|
||||||
double* internalMatrixData = propertyFrames.fortran_vec();
|
double* internalMatrixData = propertyFrames.fortran_vec();
|
||||||
|
QStringList errorMessages;
|
||||||
// Raw data transfer. Faster. Not possible when dealing with coarsening
|
if (!readBlockData(socket, (char*)(internalMatrixData), totalByteCount, errorMessages))
|
||||||
bytesRead = socket.read(((char*)(internalMatrixData)) + tIdx * timestepByteCount, timestepByteCount);
|
|
||||||
|
|
||||||
if ((qint64)timestepByteCount != bytesRead)
|
|
||||||
{
|
{
|
||||||
error("Could not read binary double data properly from socket");
|
for (int i = 0; i < errorMessages.size(); i++)
|
||||||
octave_stdout << "Cellcount: " << cellCountI*cellCountJ*cellCountK << ", Timesteps count: " << timestepCount << std::endl;
|
{
|
||||||
octave_stdout << "Timestep : " << tIdx << std::endl;
|
error(errorMessages[i].toLatin1().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
totalBytesRead += bytesRead;
|
|
||||||
|
|
||||||
OCTAVE_QUIT;
|
OCTAVE_QUIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((qint64)totalByteCount != totalBytesRead)
|
|
||||||
{
|
|
||||||
error("Could not read binary double data properly from socket");
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// Wait for available data
|
|
||||||
qint64 bytesAvailable = socket.bytesAvailable() ;
|
|
||||||
|
|
||||||
while (bytesAvailable < (qint64)totalByteCount)
|
|
||||||
{
|
|
||||||
octave_stdout << "Waiting for data. Has : " << bytesAvailable << " Needs :" << totalByteCount << std::endl;
|
|
||||||
if (!socket.waitForReadyRead(riOctavePlugin::shortTimeOutMilliSecs))
|
|
||||||
{
|
|
||||||
//error(("Waiting for data : " + socket.errorString()).toLatin1().data());
|
|
||||||
//return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
bytesAvailable = socket.bytesAvailable() ;
|
|
||||||
OCTAVE_QUIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
qint64 bytesRead = 0;
|
|
||||||
double * internalMatrixData = propertyFrames.fortran_vec();
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
char* dataBuffer = new char[totalByteCount];
|
|
||||||
bytesRead = socket.read(dataBuffer, totalByteCount);
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// Raw data transfer. Faster.
|
|
||||||
bytesRead = socket.read((char*)(internalMatrixData ), totalByteCount);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
if ((qint64)totalByteCount != bytesRead)
|
|
||||||
{
|
|
||||||
error("Could not read binary double data properly from socket");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
QString tmp = QString("riGetGridProperty : Read %1").arg(propertyName);
|
QString tmp = QString("riGetGridProperty : Read %1").arg(propertyName);
|
||||||
|
|
||||||
if (caseId < 0)
|
if (caseId < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user