mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Use block transfer for data transfer of cell properties
This commit is contained in:
@@ -6,26 +6,26 @@
|
||||
set(CPP_SOURCES
|
||||
riGetActiveCellProperty.cpp
|
||||
riSetActiveCellProperty.cpp
|
||||
riGetActiveCellInfo.cpp
|
||||
riGetMainGridDimensions.cpp
|
||||
riGetCurrentCase.cpp
|
||||
riGetCaseGroups.cpp
|
||||
riGetSelectedCases.cpp
|
||||
riGetCases.cpp
|
||||
riGetTimeStepDates.cpp
|
||||
riGetTimeStepDays.cpp
|
||||
riGetGridDimensions.cpp
|
||||
riGetCoarseningInfo.cpp
|
||||
riGetCellCenters.cpp
|
||||
riGetActiveCellCenters.cpp
|
||||
riGetCellCorners.cpp
|
||||
riGetActiveCellCorners.cpp
|
||||
# riGetActiveCellInfo.cpp
|
||||
# riGetMainGridDimensions.cpp
|
||||
# riGetCurrentCase.cpp
|
||||
# riGetCaseGroups.cpp
|
||||
# riGetSelectedCases.cpp
|
||||
# riGetCases.cpp
|
||||
# riGetTimeStepDates.cpp
|
||||
# riGetTimeStepDays.cpp
|
||||
# riGetGridDimensions.cpp
|
||||
# riGetCoarseningInfo.cpp
|
||||
# riGetCellCenters.cpp
|
||||
# riGetActiveCellCenters.cpp
|
||||
# riGetCellCorners.cpp
|
||||
# riGetActiveCellCorners.cpp
|
||||
riGetGridProperty.cpp
|
||||
riSetGridProperty.cpp
|
||||
riGetPropertyNames.cpp
|
||||
riGetWellNames.cpp
|
||||
riGetWellStatus.cpp
|
||||
riGetWellCells.cpp
|
||||
# riGetPropertyNames.cpp
|
||||
# riGetWellNames.cpp
|
||||
# riGetWellStatus.cpp
|
||||
# riGetWellCells.cpp
|
||||
)
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
#include <QtNetwork>
|
||||
#include <QStringList>
|
||||
|
||||
#include <octave/oct.h>
|
||||
|
||||
#include "riSettings.h"
|
||||
|
||||
#include "RiaSocketDataTransfer.cpp" // NB! Include cpp-file to avoid linking of additional file in oct-compile configuration
|
||||
|
||||
void getActiveCellProperty(Matrix& propertyFrames, const QString &serverName, quint16 serverPort,
|
||||
const qint64& caseId, QString propertyName, const int32NDArray& requestedTimeSteps, QString porosityModel)
|
||||
{
|
||||
@@ -63,44 +68,18 @@ void getActiveCellProperty(Matrix& propertyFrames, const QString &serverName, qu
|
||||
return;
|
||||
}
|
||||
|
||||
// Wait for available data for each timestep, then read data for each timestep
|
||||
quint64 totalByteCount = byteCount * timestepCount;
|
||||
|
||||
for (size_t tIdx = 0; tIdx < timestepCount; ++tIdx)
|
||||
double* internalMatrixData = propertyFrames.fortran_vec();
|
||||
QStringList errorMessages;
|
||||
if (!RiaSocketDataTransfer::readBlockDataFromSocket(&socket, (char*)(internalMatrixData), totalByteCount, errorMessages))
|
||||
{
|
||||
while (socket.bytesAvailable() < (qint64)byteCount)
|
||||
for (int i = 0; i < errorMessages.size(); i++)
|
||||
{
|
||||
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
|
||||
{
|
||||
error((("Waiting for timestep data number: ") + QString::number(tIdx)+ ": " + socket.errorString()).toLatin1().data());
|
||||
octave_stdout << "Active cells: " << activeCellCount << ", Timesteps: " << timestepCount << std::endl;
|
||||
return ;
|
||||
}
|
||||
OCTAVE_QUIT;
|
||||
error(errorMessages[i].toLatin1().data());
|
||||
}
|
||||
|
||||
qint64 bytesRead = 0;
|
||||
double * internalMatrixData = propertyFrames.fortran_vec();
|
||||
|
||||
#if 0
|
||||
// Raw data transfer. Faster. Not possible when dealing with coarsening
|
||||
// bytesRead = socket.read((char*)(internalMatrixData + tIdx * activeCellCount), byteCount);
|
||||
#else
|
||||
// Compatible transfer. Now the only one working
|
||||
for (size_t cIdx = 0; cIdx < activeCellCount; ++cIdx)
|
||||
{
|
||||
socketStream >> internalMatrixData[tIdx * activeCellCount + cIdx];
|
||||
|
||||
if (socketStream.status() == QDataStream::Ok) bytesRead += sizeof(double);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((qint64)byteCount != bytesRead)
|
||||
{
|
||||
error("Could not read binary double data properly from socket");
|
||||
octave_stdout << "Active cells: " << activeCellCount << ", Timesteps: " << timestepCount << std::endl;
|
||||
}
|
||||
|
||||
OCTAVE_QUIT;
|
||||
return;
|
||||
}
|
||||
|
||||
QString tmp = QString("riGetActiveCellProperty : Read %1").arg(propertyName);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <octave/oct.h>
|
||||
|
||||
#include "riSettings.h"
|
||||
#include "riSocketTools.h"
|
||||
#include "RiaSocketDataTransfer.cpp" // NB! Include cpp-file to avoid linking of additional file in oct-compile configuration
|
||||
|
||||
|
||||
void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16 serverPort,
|
||||
@@ -83,14 +83,14 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
|
||||
|
||||
double* internalMatrixData = propertyFrames.fortran_vec();
|
||||
QStringList errorMessages;
|
||||
if (!readBlockData(socket, (char*)(internalMatrixData), totalByteCount, errorMessages))
|
||||
if (!RiaSocketDataTransfer::readBlockDataFromSocket(&socket, (char*)(internalMatrixData), totalByteCount, errorMessages))
|
||||
{
|
||||
for (int i = 0; i < errorMessages.size(); i++)
|
||||
{
|
||||
error(errorMessages[i].toLatin1().data());
|
||||
}
|
||||
|
||||
OCTAVE_QUIT;
|
||||
return;
|
||||
}
|
||||
|
||||
QString tmp = QString("riGetGridProperty : Read %1").arg(propertyName);
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#include <QtNetwork>
|
||||
#include <QStringList>
|
||||
|
||||
#include <octave/oct.h>
|
||||
|
||||
#include "riSettings.h"
|
||||
#include "RiaSocketDataTransfer.cpp" // NB! Include cpp-file to avoid linking of additional file in oct-compile configuration
|
||||
|
||||
|
||||
void setEclipseProperty(const Matrix& propertyFrames, const QString &hostName, quint16 port,
|
||||
@@ -47,27 +51,29 @@ void setEclipseProperty(const Matrix& propertyFrames, const QString &hostName, q
|
||||
socketStream << (qint64)timeStepByteCount;
|
||||
|
||||
const double* internalData = propertyFrames.fortran_vec();
|
||||
qint64 dataWritten = socket.write((const char *)internalData, timeStepByteCount*timeStepCount);
|
||||
|
||||
if (dataWritten == timeStepByteCount*timeStepCount)
|
||||
QStringList errorMessages;
|
||||
if (!RiaSocketDataTransfer::writeBlockDataToSocket(&socket, (const char *)internalData, timeStepByteCount*timeStepCount, errorMessages))
|
||||
{
|
||||
QString tmp = QString("riSetActiveCellProperty : Wrote %1").arg(propertyName);
|
||||
for (int i = 0; i < errorMessages.size(); i++)
|
||||
{
|
||||
octave_stdout << errorMessages[i].toStdString();
|
||||
}
|
||||
|
||||
if (caseId == -1)
|
||||
{
|
||||
tmp += QString(" to current case.");
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp += QString(" to case with Id = %1.").arg(caseId);
|
||||
}
|
||||
octave_stdout << tmp.toStdString() << " Active Cells : " << cellCount << " Time steps : " << timeStepCount << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
QString tmp = QString("riSetActiveCellProperty : Wrote %1").arg(propertyName);
|
||||
|
||||
if (caseId == -1)
|
||||
{
|
||||
tmp += QString(" to current case.");
|
||||
}
|
||||
else
|
||||
{
|
||||
error("riSetActiveCellProperty : Was not able to write the proper amount of data to ResInsight:");
|
||||
octave_stdout << " Active Cells : " << cellCount << "Time steps : " << timeStepCount << " Data Written: " << dataWritten << " Should have written: " << timeStepCount * cellCount * sizeof(double) << std::endl;
|
||||
tmp += QString(" to case with Id = %1.").arg(caseId);
|
||||
}
|
||||
octave_stdout << tmp.toStdString() << " Active Cells : " << cellCount << " Time steps : " << timeStepCount << std::endl;
|
||||
|
||||
while(socket.bytesToWrite() && socket.state() == QAbstractSocket::ConnectedState)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#include <QtNetwork>
|
||||
#include <QStringList>
|
||||
|
||||
#include <octave/oct.h>
|
||||
|
||||
#include "riSettings.h"
|
||||
#include "RiaSocketDataTransfer.cpp" // NB! Include cpp-file to avoid linking of additional file in oct-compile configuration
|
||||
|
||||
|
||||
void setEclipseProperty(const NDArray& propertyFrames, const QString &hostName, quint16 port,
|
||||
@@ -64,41 +68,41 @@ void setEclipseProperty(const NDArray& propertyFrames, const QString &hostName,
|
||||
socketStream << (qint64)singleTimeStepByteCount;
|
||||
|
||||
const double* internalData = propertyFrames.fortran_vec();
|
||||
qint64 dataWritten = 0;
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < timeStepCount; ++tsIdx)
|
||||
|
||||
QStringList errorMessages;
|
||||
if (!RiaSocketDataTransfer::writeBlockDataToSocket(&socket, (const char *)internalData, timeStepCount*singleTimeStepByteCount, errorMessages))
|
||||
{
|
||||
dataWritten += socket.write(((const char *)internalData) + tsIdx*singleTimeStepByteCount, singleTimeStepByteCount);
|
||||
for (int i = 0; i < errorMessages.size(); i++)
|
||||
{
|
||||
octave_stdout << errorMessages[i].toStdString();
|
||||
}
|
||||
|
||||
size_t cellCount = cellCountI * cellCountJ * cellCountK;
|
||||
error("riSetGridProperty : Was not able to write the proper amount of data to ResInsight:");
|
||||
octave_stdout << " Cell count : " << cellCount << "Time steps : " << timeStepCount << std::endl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (dataWritten == singleTimeStepByteCount*timeStepCount)
|
||||
QString tmp = QString("riSetGridProperty : Wrote %1").arg(propertyName);
|
||||
|
||||
if (caseId == -1)
|
||||
{
|
||||
QString tmp = QString("riSetGridProperty : Wrote %1").arg(propertyName);
|
||||
|
||||
if (caseId == -1)
|
||||
{
|
||||
tmp += QString(" to current case,");
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp += QString(" to case with Id = %1,").arg(caseId);
|
||||
}
|
||||
|
||||
tmp += QString(" grid index: %1, ").arg(gridIndex);
|
||||
|
||||
octave_stdout << tmp.toStdString() << " Time steps : " << timeStepCount << std::endl;
|
||||
tmp += QString(" to current case,");
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t cellCount = cellCountI * cellCountJ * cellCountK;
|
||||
error("riSetGridProperty : Was not able to write the proper amount of data to ResInsight:");
|
||||
octave_stdout << " Cell count : " << cellCount << "Time steps : " << timeStepCount << " Data Written: " << dataWritten << " Should have written: " << timeStepCount * cellCount * sizeof(double) << std::endl;
|
||||
tmp += QString(" to case with Id = %1,").arg(caseId);
|
||||
}
|
||||
|
||||
tmp += QString(" grid index: %1, ").arg(gridIndex);
|
||||
|
||||
octave_stdout << tmp.toStdString() << " Time steps : " << timeStepCount << std::endl;
|
||||
|
||||
while(socket.bytesToWrite() && socket.state() == QAbstractSocket::ConnectedState)
|
||||
{
|
||||
octave_stdout << "Bytes to write: " << socket.bytesToWrite() << std::endl << std::flush;
|
||||
socket.waitForBytesWritten(2000);
|
||||
// octave_stdout << "Bytes to write: " << socket.bytesToWrite() << std::endl << std::flush;
|
||||
socket.waitForBytesWritten(riOctavePlugin::longTimeOutMilliSecs);
|
||||
OCTAVE_QUIT;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool readBlockData(QTcpSocket& socket, char* data, quint64 bytesToRead, QStringList& errorMessages)
|
||||
bool readBlockData_to_be_deleted(QTcpSocket& socket, char* data, quint64 bytesToRead, QStringList& errorMessages)
|
||||
{
|
||||
quint64 bytesRead = 0;
|
||||
int blockCount = 0;
|
||||
@@ -51,7 +51,7 @@ bool readBlockData(QTcpSocket& socket, char* data, quint64 bytesToRead, QStringL
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool writeBlockData(QTcpSocket& socket, const char* data, quint64 bytesToWrite, QStringList& errorMessages)
|
||||
bool writeBlockData_to_be_deleted(QTcpSocket& socket, const char* data, quint64 bytesToWrite, QStringList& errorMessages)
|
||||
{
|
||||
quint64 bytesWritten = 0;
|
||||
int blockCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user