Produce geometry for all cells, not per grid

p4#: 21710
This commit is contained in:
Magne Sjaastad
2013-05-24 09:54:32 +02:00
parent 5d2249aaea
commit d9750b2dd4
3 changed files with 80 additions and 124 deletions

View File

@@ -417,37 +417,36 @@ public:
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
{
int argCaseGroupId = -1;
size_t argGridIndex = 0;
QString porosityModelName;
if (args.size() == 2)
{
argGridIndex = args[1].toInt();
bool numberConversionOk = false;
int tmpValue = args[1].toInt(&numberConversionOk);
if (numberConversionOk)
{
argCaseGroupId = tmpValue;
}
else
{
porosityModelName = args[1];
}
}
else if (args.size() == 3)
{
bool numberConversionOk = false;
int tmpValue = args[2].toInt(&numberConversionOk);
int tmpValue = args[1].toInt(&numberConversionOk);
if (numberConversionOk)
{
// Two arguments, caseID and gridIndex
argCaseGroupId = args[1].toInt();
argGridIndex = args[2].toUInt();
argCaseGroupId = args[1].toUInt();
porosityModelName = args[2];
}
else
{
// Two arguments, gridIndex and porosity model
argGridIndex = args[1].toUInt();
porosityModelName = args[2];
argCaseGroupId = args[2].toUInt();
porosityModelName = args[1];
}
}
else if (args.size() > 3)
{
// Two arguments, caseID and gridIndex
argCaseGroupId = args[1].toInt();
argGridIndex = args[2].toUInt();
porosityModelName = args[3];
}
RifReaderInterface::PorosityModelResultType porosityModelEnum = RifReaderInterface::MATRIX_RESULTS;
if (porosityModelName.toUpper() == "FRACTURE")
@@ -456,7 +455,7 @@ public:
}
RimCase* rimCase = server->findReservoir(argCaseGroupId);
if (!rimCase || !rimCase->reservoirData() || (argGridIndex >= rimCase->reservoirData()->gridCount()) )
if (!rimCase || !rimCase->reservoirData())
{
// No data available
socketStream << (quint64)0 << (quint64)0 ;
@@ -464,15 +463,9 @@ public:
}
RigActiveCellInfo* actCellInfo = rimCase->reservoirData()->activeCellInfo(porosityModelEnum);
RigMainGrid* mainGrid = rimCase->reservoirData()->mainGrid();
RigGridBase* rigGrid = rimCase->reservoirData()->grid(argGridIndex);
quint64 cellCountI = (quint64)rigGrid->cellCountI();
quint64 cellCountJ = (quint64)rigGrid->cellCountJ();
quint64 cellCountK = (quint64)rigGrid->cellCountK();
size_t activeCellCount = 0;
actCellInfo->gridActiveCellCounts(argGridIndex, activeCellCount);
size_t activeCellCount = actCellInfo->globalActiveCellCount();
size_t doubleValueCount = activeCellCount * 3;
// This structure is supposed to be received by Octave using a NDArray. The ordering of this loop is
@@ -489,24 +482,15 @@ public:
quint64 coordCount = 0;
for (size_t coordIdx = 0; coordIdx < 3; coordIdx++)
{
for (size_t k = 0; k < cellCountK; k++)
for (size_t globalCellIdx = 0; globalCellIdx < mainGrid->cells().size(); globalCellIdx++)
{
for (size_t j = 0; j < cellCountJ; j++)
{
for (size_t i = 0; i < cellCountI; i++)
{
size_t localCellIdx = rigGrid->cellIndexFromIJK(i, j, k);
size_t globalCellIdx = rigGrid->globalGridCellIndex(localCellIdx);
if (!actCellInfo->isActive(globalCellIdx)) continue;
cvf::Vec3d center = rigGrid->cell(localCellIdx).center();
cvf::Vec3d center = mainGrid->cells()[globalCellIdx].center();
cellCenterValues[coordCount++] = center[coordIdx];
}
}
}
}
CVF_ASSERT(coordCount == doubleValueCount);
@@ -623,37 +607,36 @@ public:
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
{
int argCaseGroupId = -1;
size_t argGridIndex = 0;
QString porosityModelName;
if (args.size() == 2)
{
argGridIndex = args[1].toInt();
bool numberConversionOk = false;
int tmpValue = args[1].toInt(&numberConversionOk);
if (numberConversionOk)
{
argCaseGroupId = tmpValue;
}
else
{
porosityModelName = args[1];
}
}
else if (args.size() == 3)
{
bool numberConversionOk = false;
int tmpValue = args[2].toInt(&numberConversionOk);
int tmpValue = args[1].toInt(&numberConversionOk);
if (numberConversionOk)
{
// Two arguments, caseID and gridIndex
argCaseGroupId = args[1].toInt();
argGridIndex = args[2].toUInt();
argCaseGroupId = args[1].toUInt();
porosityModelName = args[2];
}
else
{
// Two arguments, gridIndex and porosity model
argGridIndex = args[1].toUInt();
porosityModelName = args[2];
argCaseGroupId = args[2].toUInt();
porosityModelName = args[1];
}
}
else if (args.size() > 3)
{
// Two arguments, caseID and gridIndex
argCaseGroupId = args[1].toInt();
argGridIndex = args[2].toUInt();
porosityModelName = args[3];
}
RifReaderInterface::PorosityModelResultType porosityModelEnum = RifReaderInterface::MATRIX_RESULTS;
if (porosityModelName.toUpper() == "FRACTURE")
@@ -662,7 +645,7 @@ public:
}
RimCase* rimCase = server->findReservoir(argCaseGroupId);
if (!rimCase || !rimCase->reservoirData() || (argGridIndex >= rimCase->reservoirData()->gridCount()) )
if (!rimCase || !rimCase->reservoirData() )
{
// No data available
socketStream << (quint64)0 << (quint64)0 ;
@@ -670,14 +653,9 @@ public:
}
RigActiveCellInfo* actCellInfo = rimCase->reservoirData()->activeCellInfo(porosityModelEnum);
RigGridBase* rigGrid = rimCase->reservoirData()->grid(argGridIndex);
RigMainGrid* mainGrid = rimCase->reservoirData()->mainGrid();
quint64 cellCountI = (quint64)rigGrid->cellCountI();
quint64 cellCountJ = (quint64)rigGrid->cellCountJ();
quint64 cellCountK = (quint64)rigGrid->cellCountK();
size_t activeCellCount = 0;
actCellInfo->gridActiveCellCounts(argGridIndex, activeCellCount);
size_t activeCellCount = actCellInfo->globalActiveCellCount();
size_t doubleValueCount = activeCellCount * 3 * 8;
// This structure is supposed to be received by Octave using a NDArray. The ordering of this loop is
@@ -698,25 +676,16 @@ public:
{
for (size_t cornerIdx = 0; cornerIdx < 8; cornerIdx++)
{
for (size_t k = 0; k < cellCountK; k++)
for (size_t globalCellIdx = 0; globalCellIdx < mainGrid->cells().size(); globalCellIdx++)
{
for (size_t j = 0; j < cellCountJ; j++)
{
for (size_t i = 0; i < cellCountI; i++)
{
size_t localCellIdx = rigGrid->cellIndexFromIJK(i, j, k);
size_t globalCellIdx = rigGrid->globalGridCellIndex(localCellIdx);
if (!actCellInfo->isActive(globalCellIdx)) continue;
rigGrid->cellCornerVertices(localCellIdx, cornerVerts);
mainGrid->cellCornerVertices(globalCellIdx, cornerVerts);
cellCornerValues[coordCount++] = cornerVerts[cornerIdx][coordIdx];
}
}
}
}
}
socketStream << (quint64)activeCellCount;
quint64 byteCount = doubleValueCount * sizeof(double);

View File

@@ -4,7 +4,7 @@
#include "riSettings.h"
void getActiveCellCenters(NDArray& cellCenterValues, const QString &hostName, quint16 port, const qint32& caseId, const quint32& gridIndex, const QString& porosityModel)
void getActiveCellCenters(NDArray& cellCenterValues, const QString &hostName, quint16 port, const qint32& caseId, const QString& porosityModel)
{
QString serverName = hostName;
quint16 serverPort = port;
@@ -22,7 +22,7 @@ void getActiveCellCenters(NDArray& cellCenterValues, const QString &hostName, qu
// Create command and send it:
QString command = QString("GetActiveCellCenters %1 %2 %3").arg(caseId).arg(gridIndex).arg(porosityModel);
QString command = QString("GetActiveCellCenters %1 %2").arg(caseId).arg(porosityModel);
QByteArray cmdBytes = command.toLatin1();
QDataStream socketStream(&socket);
@@ -91,7 +91,7 @@ void getActiveCellCenters(NDArray& cellCenterValues, const QString &hostName, qu
DEFUN_DLD (riGetActiveCellCenters, args, nargout,
"Usage:\n"
"\n"
" riGetActiveCellCenters([CaseId], GridIndex, [PorosityModel = <20>Matrix<69>|<7C>Fracture<72>] )\n"
" riGetActiveCellCenters([CaseId], [PorosityModel = <20>Matrix<69>|<7C>Fracture<72>] )\n"
"\n"
"This function returns the UTM coordinates (X, Y, Z) of the center point of all the cells in the grid.\n"
"If the CaseId is not defined, ResInsight<68>s Current Case is used.\n"
@@ -106,14 +106,7 @@ DEFUN_DLD (riGetActiveCellCenters, args, nargout,
}
int nargin = args.length ();
if (nargin < 1)
{
error("riGetActiveCellCenters: Too few arguments. The grid index argument is required.\n");
print_usage();
return octave_value_list ();
}
if (nargin > 3)
if (nargin > 2)
{
error("riGetActiveCellCenters: Too many arguments.\n");
print_usage();
@@ -121,31 +114,31 @@ DEFUN_DLD (riGetActiveCellCenters, args, nargout,
}
qint32 caseId = -1;
quint32 gridIndex = 0;
std::string porosityModel = "Matrix";
if (nargin == 1)
{
gridIndex = args(0).uint_value();
}
else if (nargin == 2)
{
if (args(0).is_numeric_type() && args(1).is_numeric_type())
if (args(0).is_numeric_type())
{
caseId = args(0).uint_value();
gridIndex = args(1).uint_value();
}
else
{
gridIndex = args(0).uint_value();
porosityModel = args(1).string_value();
porosityModel = args(0).string_value();
}
}
else if (nargin == 3)
else if (nargin == 2)
{
if (args(0).is_numeric_type())
{
caseId = args(0).uint_value();
gridIndex = args(1).uint_value();
porosityModel = args(2).string_value();
porosityModel = args(1).string_value();
}
else
{
caseId = args(1).uint_value();
porosityModel = args(0).string_value();
}
}
if (porosityModel != "Matrix" && porosityModel != "Fracture")
@@ -156,7 +149,7 @@ DEFUN_DLD (riGetActiveCellCenters, args, nargout,
}
NDArray cellCenterValues;
getActiveCellCenters(cellCenterValues, "127.0.0.1", 40001, caseId, gridIndex, porosityModel.c_str());
getActiveCellCenters(cellCenterValues, "127.0.0.1", 40001, caseId, porosityModel.c_str());
return octave_value(cellCenterValues);
}

View File

@@ -4,7 +4,7 @@
#include "riSettings.h"
void getActiveCellCorners(NDArray& cellCornerValues, const QString &hostName, quint16 port, const qint32& caseId, const quint32& gridIndex, const QString& porosityModel)
void getActiveCellCorners(NDArray& cellCornerValues, const QString &hostName, quint16 port, const qint32& caseId, const QString& porosityModel)
{
QString serverName = hostName;
quint16 serverPort = port;
@@ -22,7 +22,7 @@ void getActiveCellCorners(NDArray& cellCornerValues, const QString &hostName, qu
// Create command and send it:
QString command = QString("GetActiveCellCorners %1 %2 %3").arg(caseId).arg(gridIndex).arg(porosityModel);
QString command = QString("GetActiveCellCorners %1 %2").arg(caseId).arg(porosityModel);
QByteArray cmdBytes = command.toLatin1();
QDataStream socketStream(&socket);
@@ -91,7 +91,7 @@ void getActiveCellCorners(NDArray& cellCornerValues, const QString &hostName, qu
DEFUN_DLD (riGetActiveCellCorners, args, nargout,
"Usage:\n"
"\n"
" riGetActiveCellCorners([CaseId], GridIndex, [PorosityModel = <20>Matrix<69>|<7C>Fracture<72>] )\n"
" riGetActiveCellCorners([CaseId], [PorosityModel = <20>Matrix<69>|<7C>Fracture<72>] )\n"
"\n"
"This function returns the UTM coordinates (X, Y, Z) of the 8 corners of each of the active cells.\n"
"If the CaseId is not defined, ResInsight<68>s Current Case is used.\n"
@@ -106,14 +106,8 @@ DEFUN_DLD (riGetActiveCellCorners, args, nargout,
}
int nargin = args.length ();
if (nargin < 1)
{
error("riGetActiveCellCorners: Too few arguments. The grid index argument is required.\n");
print_usage();
return octave_value_list ();
}
if (nargin > 3)
if (nargin > 2)
{
error("riGetActiveCellCorners: Too many arguments.\n");
print_usage();
@@ -121,31 +115,31 @@ DEFUN_DLD (riGetActiveCellCorners, args, nargout,
}
qint32 caseId = -1;
quint32 gridIndex = 0;
std::string porosityModel = "Matrix";
if (nargin == 1)
{
gridIndex = args(0).uint_value();
}
else if (nargin == 2)
{
if (args(0).is_numeric_type() && args(1).is_numeric_type())
if (args(0).is_numeric_type())
{
caseId = args(0).uint_value();
gridIndex = args(1).uint_value();
}
else
{
gridIndex = args(0).uint_value();
porosityModel = args(1).string_value();
porosityModel = args(0).string_value();
}
}
else if (nargin == 3)
else if (nargin == 2)
{
if (args(0).is_numeric_type())
{
caseId = args(0).uint_value();
gridIndex = args(1).uint_value();
porosityModel = args(2).string_value();
porosityModel = args(1).string_value();
}
else
{
caseId = args(1).uint_value();
porosityModel = args(0).string_value();
}
}
if (porosityModel != "Matrix" && porosityModel != "Fracture")
@@ -156,7 +150,7 @@ DEFUN_DLD (riGetActiveCellCorners, args, nargout,
}
NDArray cellCornerValues;
getActiveCellCorners(cellCornerValues, "127.0.0.1", 40001, caseId, gridIndex, porosityModel.c_str());
getActiveCellCorners(cellCornerValues, "127.0.0.1", 40001, caseId, porosityModel.c_str());
return octave_value(cellCornerValues);
}