Added flag to control how to do IO with sockets

This commit is contained in:
Magne Sjaastad
2014-04-01 13:02:52 +02:00
parent 343dba02f8
commit 7a07b2926e
4 changed files with 102 additions and 30 deletions

View File

@@ -34,6 +34,8 @@
#include "RigCaseCellResultsData.h"
#include <QTcpSocket>
#include "RiaApplication.h"
#include "RiaPreferences.h"
//--------------------------------------------------------------------------------------------------
@@ -241,32 +243,66 @@ public:
// dv(3) = 8;
// dv(4) = 3;
std::vector<double> cellCornerValues(doubleValueCount);
cvf::Vec3d cornerVerts[8];
quint64 coordCount = 0;
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
cvf::Timer timer;
if (RiaApplication::instance()->preferences()->useStreamTransfer())
{
for (size_t cornerIdx = 0; cornerIdx < 8; cornerIdx++)
cvf::Vec3d cornerVerts[8];
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
{
size_t cornerIndexMapping = cellCornerMappingEclipse[cornerIdx];
for (size_t k = 0; k < cellCountK; k++)
for (size_t cornerIdx = 0; cornerIdx < 8; cornerIdx++)
{
for (size_t j = 0; j < cellCountJ; j++)
{
for (size_t i = 0; i < cellCountI; i++)
{
size_t localCellIdx = rigGrid->cellIndexFromIJK(i, j, k);
rigGrid->cellCornerVertices(localCellIdx, cornerVerts);
size_t cornerIndexMapping = cellCornerMappingEclipse[cornerIdx];
cellCornerValues[coordCount++] = cornerVerts[cornerIndexMapping][coordIdx];
for (size_t k = 0; k < cellCountK; k++)
{
for (size_t j = 0; j < cellCountJ; j++)
{
for (size_t i = 0; i < cellCountI; i++)
{
size_t localCellIdx = rigGrid->cellIndexFromIJK(i, j, k);
rigGrid->cellCornerVertices(localCellIdx, cornerVerts);
socketStream << cornerVerts[cornerIndexMapping][coordIdx];
}
}
}
}
}
}
else
{
std::vector<double> cellCornerValues(doubleValueCount);
cvf::Vec3d cornerVerts[8];
quint64 coordCount = 0;
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
{
for (size_t cornerIdx = 0; cornerIdx < 8; cornerIdx++)
{
size_t cornerIndexMapping = cellCornerMappingEclipse[cornerIdx];
server->currentClient()->write((const char *)cellCornerValues.data(), byteCount);
for (size_t k = 0; k < cellCountK; k++)
{
for (size_t j = 0; j < cellCountJ; j++)
{
for (size_t i = 0; i < cellCountI; i++)
{
size_t localCellIdx = rigGrid->cellIndexFromIJK(i, j, k);
rigGrid->cellCornerVertices(localCellIdx, cornerVerts);
cellCornerValues[coordCount++] = cornerVerts[cornerIndexMapping][coordIdx];
}
}
}
}
}
server->currentClient()->write((const char *)cellCornerValues.data(), byteCount);
}
double totalTimeMS = timer.time() * 1000.0;
QString resultInfo = QString("Total time '%1 ms'").arg(totalTimeMS);
server->errorMessageDialog()->showMessage(resultInfo);
return true;
}

View File

@@ -40,6 +40,8 @@
#include "Rim3dOverlayInfoConfig.h"
#include <QTcpSocket>
#include "RiaApplication.h"
#include "RiaPreferences.h"
//--------------------------------------------------------------------------------------------------
@@ -305,30 +307,61 @@ public:
socketStream << timestepCount;
size_t valueIdx = 0;
std::vector<double> values(rigGrid->cellCount());
cvf::Timer timer;
for (size_t tsIdx = 0; tsIdx < timestepCount; tsIdx++)
if (RiaApplication::instance()->preferences()->useStreamTransfer())
{
cvf::ref<cvf::StructGridScalarDataAccess> cellCenterDataAccessObject = rimCase->reservoirData()->dataAccessObject(rigGrid, porosityModelEnum, requestedTimesteps[tsIdx], scalarResultIndex);
if (cellCenterDataAccessObject.isNull())
for (size_t tsIdx = 0; tsIdx < timestepCount; tsIdx++)
{
continue;
}
for (size_t cellIdx = 0; cellIdx < rigGrid->cellCount(); cellIdx++)
{
double cellValue = cellCenterDataAccessObject->cellScalar(cellIdx);
if (cellValue == HUGE_VAL)
cvf::ref<cvf::StructGridScalarDataAccess> cellCenterDataAccessObject = rimCase->reservoirData()->dataAccessObject(rigGrid, porosityModelEnum, requestedTimesteps[tsIdx], scalarResultIndex);
if (cellCenterDataAccessObject.isNull())
{
cellValue = 0.0;
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
{
std::vector<double> values(rigGrid->cellCount());
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;
}
values[valueIdx++] = cellValue;
}
values[cellIdx] = cellValue;
}
server->currentClient()->write((const char *)values.data(), rigGrid->cellCount() * sizeof(double));
}
double totalTimeMS = timer.time() * 1000.0;
QString resultInfo = QString("Total time '%1 ms'").arg(totalTimeMS);
server->errorMessageDialog()->showMessage(resultInfo);
return true;
}
};