mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Temporarily fixes for handling communication of more than 2GB data to/from octave
This commit is contained in:
parent
c74851bfff
commit
14521bd5b0
@ -67,7 +67,7 @@ void getActiveCellProperty(Matrix& propertyFrames, const QString &serverName, qu
|
|||||||
|
|
||||||
for (size_t tIdx = 0; tIdx < timestepCount; ++tIdx)
|
for (size_t tIdx = 0; tIdx < timestepCount; ++tIdx)
|
||||||
{
|
{
|
||||||
while (socket.bytesAvailable() < (int)byteCount)
|
while (socket.bytesAvailable() < (qint64)byteCount)
|
||||||
{
|
{
|
||||||
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
|
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
|
||||||
{
|
{
|
||||||
@ -94,7 +94,7 @@ void getActiveCellProperty(Matrix& propertyFrames, const QString &serverName, qu
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((int)byteCount != bytesRead)
|
if ((qint64)byteCount != bytesRead)
|
||||||
{
|
{
|
||||||
error("Could not read binary double data properly from socket");
|
error("Could not read binary double data properly from socket");
|
||||||
octave_stdout << "Active cells: " << activeCellCount << ", Timesteps: " << timestepCount << std::endl;
|
octave_stdout << "Active cells: " << activeCellCount << ", Timesteps: " << timestepCount << std::endl;
|
||||||
|
@ -22,7 +22,7 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
|
|||||||
QString command;
|
QString command;
|
||||||
command += "GetGridProperty " + QString::number(caseId) + " " + QString::number(gridIdx) + " " + propertyName + " " + porosityModel;
|
command += "GetGridProperty " + QString::number(caseId) + " " + QString::number(gridIdx) + " " + propertyName + " " + porosityModel;
|
||||||
|
|
||||||
for (int i = 0; i < requestedTimeSteps.length(); ++i)
|
for (qint64 i = 0; i < requestedTimeSteps.length(); ++i)
|
||||||
{
|
{
|
||||||
if (i == 0) command += " ";
|
if (i == 0) command += " ";
|
||||||
command += QString::number(static_cast<int>(requestedTimeSteps.elem(i)) - 1); // To make the index 0-based
|
command += QString::number(static_cast<int>(requestedTimeSteps.elem(i)) - 1); // To make the index 0-based
|
||||||
@ -36,7 +36,7 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
|
|||||||
|
|
||||||
// Get response. First wait for the header
|
// Get response. First wait for the header
|
||||||
|
|
||||||
while (socket.bytesAvailable() < (int)(4*sizeof(quint64)))
|
while (socket.bytesAvailable() < (qint64)(4*sizeof(quint64)))
|
||||||
{
|
{
|
||||||
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
|
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
|
||||||
{
|
{
|
||||||
@ -48,6 +48,7 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
|
|||||||
// Read sizes
|
// Read sizes
|
||||||
|
|
||||||
quint64 totalByteCount;
|
quint64 totalByteCount;
|
||||||
|
|
||||||
quint64 cellCountI;
|
quint64 cellCountI;
|
||||||
quint64 cellCountJ;
|
quint64 cellCountJ;
|
||||||
quint64 cellCountK;
|
quint64 cellCountK;
|
||||||
@ -59,6 +60,9 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
|
|||||||
socketStream >> timestepCount;
|
socketStream >> timestepCount;
|
||||||
|
|
||||||
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");
|
||||||
@ -75,29 +79,92 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
|
|||||||
propertyFrames.resize(dv);
|
propertyFrames.resize(dv);
|
||||||
|
|
||||||
|
|
||||||
// Wait for available data
|
#if 1
|
||||||
|
// Wait for available data for each timestep, then read data for each timestep
|
||||||
while (socket.bytesAvailable() < (int)totalByteCount)
|
|
||||||
|
qint64 totalBytesRead = 0;
|
||||||
|
|
||||||
|
for (size_t tIdx = 0; tIdx < timestepCount; ++tIdx)
|
||||||
{
|
{
|
||||||
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
|
qint64 bytesAvailable = socket.bytesAvailable() ;
|
||||||
|
|
||||||
|
while ( bytesAvailable < (qint64)timestepByteCount)
|
||||||
{
|
{
|
||||||
error(("Waiting for data : " + socket.errorString()).toLatin1().data());
|
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
|
||||||
return ;
|
{
|
||||||
|
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();
|
||||||
|
|
||||||
|
// Raw data transfer. Faster. Not possible when dealing with coarsening
|
||||||
|
bytesRead = socket.read(((char*)(internalMatrixData)) + tIdx * timestepByteCount, timestepByteCount);
|
||||||
|
|
||||||
|
if ((qint64)timestepByteCount != bytesRead)
|
||||||
|
{
|
||||||
|
error("Could not read binary double data properly from socket");
|
||||||
|
octave_stdout << "Cellcount: " << cellCountI*cellCountJ*cellCountK << ", Timesteps count: " << timestepCount << std::endl;
|
||||||
|
octave_stdout << "Timestep : " << tIdx << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
totalBytesRead += bytesRead;
|
||||||
|
|
||||||
|
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;
|
OCTAVE_QUIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 bytesRead = 0;
|
qint64 bytesRead = 0;
|
||||||
double * internalMatrixData = propertyFrames.fortran_vec();
|
double * internalMatrixData = propertyFrames.fortran_vec();
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
char* dataBuffer = new char[totalByteCount];
|
||||||
|
bytesRead = socket.read(dataBuffer, totalByteCount);
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
// Raw data transfer. Faster.
|
// Raw data transfer. Faster.
|
||||||
bytesRead = socket.read((char*)(internalMatrixData ), totalByteCount);
|
bytesRead = socket.read((char*)(internalMatrixData ), totalByteCount);
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((int)totalByteCount != bytesRead)
|
|
||||||
|
if ((qint64)totalByteCount != bytesRead)
|
||||||
{
|
{
|
||||||
error("Could not read binary double data properly from socket");
|
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)
|
||||||
|
@ -64,8 +64,13 @@ void setEclipseProperty(const NDArray& propertyFrames, const QString &hostName,
|
|||||||
socketStream << (qint64)singleTimeStepByteCount;
|
socketStream << (qint64)singleTimeStepByteCount;
|
||||||
|
|
||||||
const double* internalData = propertyFrames.fortran_vec();
|
const double* internalData = propertyFrames.fortran_vec();
|
||||||
int dataWritten = socket.write((const char *)internalData, singleTimeStepByteCount*timeStepCount);
|
qint64 dataWritten = 0;
|
||||||
|
|
||||||
|
for (size_t tsIdx = 0; tsIdx < timeStepCount; ++tsIdx)
|
||||||
|
{
|
||||||
|
dataWritten += socket.write(((const char *)internalData) + tsIdx*singleTimeStepByteCount, singleTimeStepByteCount);
|
||||||
|
}
|
||||||
|
|
||||||
if (dataWritten == singleTimeStepByteCount*timeStepCount)
|
if (dataWritten == singleTimeStepByteCount*timeStepCount)
|
||||||
{
|
{
|
||||||
QString tmp = QString("riSetGridProperty : Wrote %1").arg(propertyName);
|
QString tmp = QString("riSetGridProperty : Wrote %1").arg(propertyName);
|
||||||
@ -92,8 +97,8 @@ void setEclipseProperty(const NDArray& propertyFrames, const QString &hostName,
|
|||||||
|
|
||||||
while(socket.bytesToWrite() && socket.state() == QAbstractSocket::ConnectedState)
|
while(socket.bytesToWrite() && socket.state() == QAbstractSocket::ConnectedState)
|
||||||
{
|
{
|
||||||
// octave_stdout << "Bytes to write: " << socket.bytesToWrite() << std::endl;
|
octave_stdout << "Bytes to write: " << socket.bytesToWrite() << std::endl << std::flush;
|
||||||
socket.waitForBytesWritten(riOctavePlugin::longTimeOutMilliSecs);
|
socket.waitForBytesWritten(2000);
|
||||||
OCTAVE_QUIT;
|
OCTAVE_QUIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user