Merge pull request #169 from OPM/octave-64-bit-investigation

Implemented workaround for Qt limitation of 2Gb data for socket transfer
This commit is contained in:
Magne Sjaastad 2014-04-24 07:51:20 +02:00
commit 03c0c93fe3
43 changed files with 1054 additions and 448 deletions

View File

@ -699,7 +699,7 @@ bool RiaApplication::openInputEclipseCaseFromFileNames(const QStringList& fileNa
//--------------------------------------------------------------------------------------------------
void RiaApplication::createMockModel()
{
openEclipseCase("Result Mock Debug Model Simple", "Result Mock Debug Model Simple");
openEclipseCase(RimDefines::mockModelBasic(), RimDefines::mockModelBasic());
}
//--------------------------------------------------------------------------------------------------
@ -707,7 +707,7 @@ void RiaApplication::createMockModel()
//--------------------------------------------------------------------------------------------------
void RiaApplication::createResultsMockModel()
{
openEclipseCase("Result Mock Debug Model With Results", "Result Mock Debug Model With Results");
openEclipseCase(RimDefines::mockModelBasicWithResults(), RimDefines::mockModelBasicWithResults());
}
@ -716,7 +716,16 @@ void RiaApplication::createResultsMockModel()
//--------------------------------------------------------------------------------------------------
void RiaApplication::createLargeResultsMockModel()
{
openEclipseCase("Result Mock Debug Model Large With Results", "Result Mock Debug Model Large With Results");
openEclipseCase(RimDefines::mockModelLargeWithResults(), RimDefines::mockModelLargeWithResults());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::createMockModelCustomized()
{
openEclipseCase(RimDefines::mockModelCustomized(), RimDefines::mockModelCustomized());
}
//--------------------------------------------------------------------------------------------------
@ -724,7 +733,7 @@ void RiaApplication::createLargeResultsMockModel()
//--------------------------------------------------------------------------------------------------
void RiaApplication::createInputMockModel()
{
openInputEclipseCaseFromFileNames(QStringList("Input Mock Debug Model Simple"));
openInputEclipseCaseFromFileNames(QStringList(RimDefines::mockModelBasicInputCase()));
}
//--------------------------------------------------------------------------------------------------

View File

@ -81,6 +81,7 @@ public:
void createMockModel();
void createResultsMockModel();
void createLargeResultsMockModel();
void createMockModelCustomized();
void createInputMockModel();
QString defaultFileDialogDirectory(const QString& dialogName);

View File

@ -43,7 +43,6 @@ set( APPLICATION_FILES
set( USER_INTERFACE_FILES
UserInterface/RiuCursors.cpp
UserInterface/RiuMainWindow.cpp
UserInterface/RiuPreferencesDialog.cpp
UserInterface/RiuResultInfoPanel.cpp
UserInterface/RiuViewer.cpp
UserInterface/RiuSimpleHistogramWidget.cpp
@ -59,6 +58,7 @@ set( SOCKET_INTERFACE_FILES
SocketInterface/RiaPropertyDataCommands.cpp
SocketInterface/RiaWellDataCommands.cpp
SocketInterface/RiaSocketTools.cpp
SocketInterface/RiaSocketDataTransfer.cpp
)
@ -98,7 +98,6 @@ set ( QT_MOC_HEADERS
ProjectDataModel/RimMimeData.h
UserInterface/RiuMainWindow.h
UserInterface/RiuPreferencesDialog.h
UserInterface/RiuResultInfoPanel.h
UserInterface/RiuViewer.h
UserInterface/RiuProcessMonitor.h
@ -155,6 +154,8 @@ list( REMOVE_ITEM RAW_SOURCES
Application/RiaImageCompareReporter.cpp
Application/RiaRegressionTest.cpp
SocketInterface/RiaSocketDataTransfer.cpp
FileInterface/RifEclipseInputFileTools.cpp
FileInterface/RifEclipseOutputFileTools.cpp
FileInterface/RifEclipseRestartFilesetAccess.cpp

View File

@ -175,3 +175,11 @@ void RifReaderMockModel::populateReservoir(RigCaseData* eclipseCase)
m_reservoirBuilder.populateReservoir(eclipseCase);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderMockModel::enableWellData(bool enableWellData)
{
m_reservoirBuilder.enableWellData(enableWellData);
}

View File

@ -30,6 +30,7 @@ public:
void setWorldCoordinates(cvf::Vec3d minWorldCoordinate, cvf::Vec3d maxWorldCoordinate);
void setGridPointDimensions(const cvf::Vec3st& gridPointDimensions);
void setResultInfo(size_t resultCount, size_t timeStepCount);
void enableWellData(bool enableWellData);
void addLocalGridRefinement(const cvf::Vec3st& minCellPosition, const cvf::Vec3st& maxCellPosition, const cvf::Vec3st& singleCellRefinementFactors);

View File

@ -46,6 +46,7 @@ ${CEE_CURRENT_LIST_DIR}RimCommandObject.h
${CEE_CURRENT_LIST_DIR}RimTools.h
${CEE_CURRENT_LIST_DIR}RimFault.h
${CEE_CURRENT_LIST_DIR}RimFaultCollection.h
${CEE_CURRENT_LIST_DIR}RimMockModelSettings.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -90,6 +91,7 @@ ${CEE_CURRENT_LIST_DIR}RimCommandObject.cpp
${CEE_CURRENT_LIST_DIR}RimTools.cpp
${CEE_CURRENT_LIST_DIR}RimFault.cpp
${CEE_CURRENT_LIST_DIR}RimFaultCollection.cpp
${CEE_CURRENT_LIST_DIR}RimMockModelSettings.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -41,8 +41,16 @@ public:
static QString undefinedResultName() { return "None"; }
static QString undefinedGridFaultName() { return "Undefined grid faults"; }
static QString combinedTransmissibilityResultName() { return "TRANSXYZ"; }
static QString ternarySaturationResultName() { return "TERNARY"; }
// Mock model text identifiers
static QString mockModelBasic() { return "Result Mock Debug Model Simple"; }
static QString mockModelBasicWithResults() { return "Result Mock Debug Model With Results"; }
static QString mockModelLargeWithResults() { return "Result Mock Debug Model Large With Results"; }
static QString mockModelCustomized() { return "Result Mock Debug Model Customized"; }
static QString mockModelBasicInputCase() { return "Input Mock Debug Model Simple"; }
};

View File

@ -77,7 +77,7 @@ RimInputCase::~RimInputCase()
//--------------------------------------------------------------------------------------------------
void RimInputCase::openDataFileSet(const QStringList& fileNames)
{
if (fileNames.contains("Input Mock Debug Model Simple"))
if (fileNames.contains(RimDefines::mockModelBasicInputCase()))
{
cvf::ref<RifReaderInterface> readerInterface = this->createMockModel(fileNames[0]);
results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
@ -184,7 +184,7 @@ bool RimInputCase::openEclipseGridFile()
{
cvf::ref<RifReaderInterface> readerInterface;
if (m_gridFileName().contains("Input Mock Debug Model Simple"))
if (m_gridFileName().contains(RimDefines::mockModelBasicInputCase()))
{
readerInterface = this->createMockModel(this->m_gridFileName());
}
@ -377,7 +377,7 @@ cvf::ref<RifReaderInterface> RimInputCase::createMockModel(QString modelName)
cvf::ref<RigCaseData> reservoir = new RigCaseData;
cvf::ref<RifReaderMockModel> mockFileInterface = new RifReaderMockModel;
if (modelName == "Input Mock Debug Model Simple")
if (modelName == RimDefines::mockModelBasicInputCase())
{
m_gridFileName = modelName;

View File

@ -0,0 +1,77 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaStdInclude.h"
#include "RimMockModelSettings.h"
CAF_PDM_SOURCE_INIT(RimMockModelSettings, "MockModelSettings");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMockModelSettings::RimMockModelSettings()
{
CAF_PDM_InitObject("Mock Model Settings", "", "", "");
CAF_PDM_InitField(&cellCountX, "CellCountX", quint64(100), "Cell Count X", "", "", "");
CAF_PDM_InitField(&cellCountY, "CellCountY", quint64(100), "Cell Count Y", "", "", "");
CAF_PDM_InitField(&cellCountZ, "CellCountZ", quint64(10), "Cell Count Z", "", "", "");
CAF_PDM_InitFieldNoDefault(&totalCellCount, "TotalCellCount", "Total Cell Count", "", "", "");
totalCellCount.setUiReadOnly(true);
CAF_PDM_InitField(&resultCount, "ResultCount", quint64(3), "Result Count", "", "", "");
CAF_PDM_InitField(&timeStepCount, "TimeStepCount", quint64(10), "Time Step Count", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMockModelSettings::~RimMockModelSettings()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMockModelSettings::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
totalCellCount = cellCountX * cellCountY * cellCountZ;
totalCellCount.updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMockModelSettings::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
caf::PdmUiGroup* gridSizeGroup = uiOrdering.addNewGroup("Grid size");
gridSizeGroup->add(&cellCountX);
gridSizeGroup->add(&cellCountY);
gridSizeGroup->add(&cellCountZ);
gridSizeGroup->add(&totalCellCount);
caf::PdmUiGroup* resultGroup = uiOrdering.addNewGroup("Results");
resultGroup->add(&resultCount);
resultGroup->add(&timeStepCount);
}

View File

@ -18,32 +18,35 @@
#pragma once
#include <QDialog>
namespace caf
{
class PdmObject;
class PdmUiPropertyView;
}
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
//==================================================================================================
//
//
//
///
///
//==================================================================================================
class RiuPreferencesDialog : public QDialog
class RimMockModelSettings : public caf::PdmObject
{
Q_OBJECT
CAF_PDM_HEADER_INIT;
public:
RiuPreferencesDialog(QWidget* parent, caf::PdmObject* object, const QString& windowTitle);
private:
void setupUi();
RimMockModelSettings();
virtual ~RimMockModelSettings();
caf::PdmField<quint64> cellCountX;
caf::PdmField<quint64> cellCountY;
caf::PdmField<quint64> cellCountZ;
caf::PdmField<quint64> totalCellCount;
caf::PdmField<quint64> resultCount;
caf::PdmField<quint64> timeStepCount;
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
private:
QString m_windowTitle;
caf::PdmObject* m_pdmObject;
caf::PdmUiPropertyView* m_pdmUiPropertyView;
};

View File

@ -17,6 +17,13 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiaStdInclude.h"
#include "cafProgressInfo.h"
#include "cafPdmSettings.h"
#include "cafPdmFieldCvfMat4d.h"
#include "cafPdmFieldCvfColor.h"
#include "cafPdmUiPropertyDialog.h"
#include "RimResultCase.h"
#include "RigCaseData.h"
#include "RifReaderEclipseOutput.h"
@ -24,7 +31,7 @@
#include "RimReservoirView.h"
#include "RifReaderMockModel.h"
#include "RifReaderEclipseInput.h"
#include "cafProgressInfo.h"
#include "RimProject.h"
#include "RifEclipseOutputFileTools.h"
#include "RiaApplication.h"
@ -34,8 +41,6 @@
#include "RimReservoirCellResultsCacher.h"
#include "RimWellPathCollection.h"
#include "cafPdmFieldCvfMat4d.h"
#include "cafPdmFieldCvfColor.h"
#include "RimResultSlot.h"
#include "RimCellEdgeResultSlot.h"
#include "RimCellRangeFilterCollection.h"
@ -45,6 +50,7 @@
#include "RimOilField.h"
#include "RimAnalysisModels.h"
#include "RiaPreferences.h"
#include "RimMockModelSettings.h"
CAF_PDM_SOURCE_INIT(RimResultCase, "EclipseCase");
//--------------------------------------------------------------------------------------------------
@ -199,7 +205,7 @@ cvf::ref<RifReaderInterface> RimResultCase::createMockModel(QString modelName)
cvf::ref<RifReaderMockModel> mockFileInterface = new RifReaderMockModel;
cvf::ref<RigCaseData> reservoir = new RigCaseData;
if (modelName == "Result Mock Debug Model Simple")
if (modelName == RimDefines::mockModelBasic())
{
// Create the mock file interface and and RigSerervoir and set them up.
mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(20, 20, 20));
@ -221,7 +227,7 @@ cvf::ref<RifReaderInterface> RimResultCase::createMockModel(QString modelName)
//reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
}
}
else if (modelName == "Result Mock Debug Model With Results")
else if (modelName == RimDefines::mockModelBasicWithResults())
{
mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(-20, -20, -20));
mockFileInterface->setGridPointDimensions(cvf::Vec3st(5, 10, 20));
@ -234,7 +240,7 @@ cvf::ref<RifReaderInterface> RimResultCase::createMockModel(QString modelName)
cvf::Vec3d& tmp = reservoir->mainGrid()->nodes()[1];
tmp += cvf::Vec3d(1, 0, 0);
}
else if (modelName =="Result Mock Debug Model Large With Results")
else if (modelName == RimDefines::mockModelLargeWithResults())
{
double startX = 0;
double startY = 0;
@ -262,6 +268,45 @@ cvf::ref<RifReaderInterface> RimResultCase::createMockModel(QString modelName)
mockFileInterface->open("", reservoir.p());
}
else if (modelName == RimDefines::mockModelCustomized())
{
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
RimMockModelSettings rimMockModelSettings;
caf::Settings::readFieldsFromApplicationStore(&rimMockModelSettings);
caf::PdmUiPropertyDialog propertyDialog(NULL, &rimMockModelSettings, "Customize Mock Model");
if (propertyDialog.exec() == QDialog::Accepted)
{
QApplication::restoreOverrideCursor();
caf::Settings::writeFieldsToApplicationStore(&rimMockModelSettings);
double startX = 0;
double startY = 0;
double startZ = 0;
double widthX = 6000;
double widthY = 12000;
double widthZ = 500;
// Test code to simulate UTM coordinates
double offsetX = 400000;
double offsetY = 6000000;
double offsetZ = 0;
mockFileInterface->setWorldCoordinates(cvf::Vec3d(startX + offsetX, startY + offsetY, startZ + offsetZ), cvf::Vec3d(startX + widthX + offsetX, startY + widthY + offsetY, startZ + widthZ + offsetZ));
mockFileInterface->setGridPointDimensions(cvf::Vec3st(rimMockModelSettings.cellCountX + 1, rimMockModelSettings.cellCountY + 1, rimMockModelSettings.cellCountZ + 1));
mockFileInterface->setResultInfo(rimMockModelSettings.resultCount, rimMockModelSettings.timeStepCount);
mockFileInterface->enableWellData(false);
mockFileInterface->open("", reservoir.p());
}
else
{
QApplication::restoreOverrideCursor();
}
}
this->setReservoirData( reservoir.p() );

View File

@ -19,6 +19,9 @@
//#include "RiaStdInclude.h"
#include "cafPdmDocument.h"
#include "cafPdmFieldCvfColor.h"
#include "cafPdmFieldCvfMat4d.h"
#include "cafPdmUiPropertyDialog.h"
#include <QAction>
#include <QMenu>
@ -37,7 +40,6 @@
#include "RimInputPropertyCollection.h"
#include "RimExportInputPropertySettings.h"
#include "RiaPreferences.h"
#include "RiuPreferencesDialog.h"
#include "RifEclipseInputFileTools.h"
#include "RimInputCase.h"
#include "RimBinaryExportSettings.h"
@ -59,9 +61,6 @@
#include "RimWellPathCollection.h"
#include "RimReservoirCellResultsCacher.h"
#include "Rim3dOverlayInfoConfig.h"
#include "cafPdmFieldCvfColor.h"
#include "cafPdmFieldCvfMat4d.h"
#include "RimProject.h"
#include "RimOilField.h"
#include "RimAnalysisModels.h"
@ -834,8 +833,8 @@ void RimUiTreeView::slotWriteInputProperty()
exportSettings.fileName = outputFileName;
}
RiuPreferencesDialog preferencesDialog(this, &exportSettings, "Export Eclipse Property to Text File");
if (preferencesDialog.exec() == QDialog::Accepted)
caf::PdmUiPropertyDialog propertyDialog(this, &exportSettings, "Export Eclipse Property to Text File");
if (propertyDialog.exec() == QDialog::Accepted)
{
bool isOk = RifEclipseInputFileTools::writePropertyToTextFile(exportSettings.fileName, inputReservoir->reservoirData(), 0, inputProperty->resultName, exportSettings.eclipseKeyword);
if (isOk)
@ -887,8 +886,8 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty()
exportSettings.fileName = outputFileName;
}
RiuPreferencesDialog preferencesDialog(this, &exportSettings, "Export Binary Eclipse Data to Text File");
if (preferencesDialog.exec() == QDialog::Accepted)
caf::PdmUiPropertyDialog propertyDialog(this, &exportSettings, "Export Binary Eclipse Data to Text File");
if (propertyDialog.exec() == QDialog::Accepted)
{
size_t timeStep = resultSlot->reservoirView()->currentTimeStep();
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(resultSlot->porosityModel());

View File

@ -193,6 +193,14 @@ void RigActiveCellInfo::clear()
m_activeCellsBoundingBox.reset();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigActiveCellInfo::isCoarseningActive() const
{
return m_globalCellResultCount != m_globalActiveCellCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -36,6 +36,7 @@ public:
size_t globalCellCount() const;
size_t globalActiveCellCount() const;
size_t globalCellResultCount() const;
bool isCoarseningActive() const;
bool isActive(size_t globalCellIndex) const;
size_t cellResultIndex(size_t globalCellIndex) const;

View File

@ -34,6 +34,7 @@ RigReservoirBuilderMock::RigReservoirBuilderMock()
m_resultCount = 0;
m_timeStepCount = 0;
m_gridPointDimensions = cvf::Vec3st::ZERO;
m_enableWellData = true;
}
//--------------------------------------------------------------------------------------------------
@ -134,10 +135,14 @@ void RigReservoirBuilderMock::appendCubeNodes(const cvf::Vec3d& min, const cvf::
void RigReservoirBuilderMock::appendCells(size_t nodeStartIndex, size_t cellCount, RigGridBase* hostGrid, std::vector<RigCell>& cells)
{
size_t activeCellIndex = 0;
size_t i;
for (i = 0; i < cellCount; i++)
long long i;
cells.resize(cellCount);
#pragma omp parallel for
for (i = 0; i < static_cast<long long>(cellCount); i++)
{
RigCell riCell;
RigCell& riCell = cells[i];
riCell.setHostGrid(hostGrid);
riCell.setCellIndex(i);
@ -164,8 +169,6 @@ void RigReservoirBuilderMock::appendCells(size_t nodeStartIndex, size_t cellCoun
riCell.setActiveIndexInMatrixModel(activeCellIndex++);
}
*/
cells.push_back(riCell);
}
}
@ -246,7 +249,10 @@ void RigReservoirBuilderMock::populateReservoir(RigCaseData* eclipseCase)
eclipseCase->mainGrid()->setGridPointDimensions(m_gridPointDimensions);
addWellData(eclipseCase, eclipseCase->mainGrid());
if (m_enableWellData)
{
addWellData(eclipseCase, eclipseCase->mainGrid());
}
addFaults(eclipseCase);
@ -346,13 +352,15 @@ bool RigReservoirBuilderMock::dynamicResult(RigCaseData* eclipseCase, const QStr
double scaleValue = 1.0 + resultIndex * 0.1;
double offsetValue = 100 * resultIndex;
size_t k;
for (k = 0; k < eclipseCase->mainGrid()->cells().size(); k++)
values->resize(eclipseCase->mainGrid()->cells().size());
#pragma omp parallel for
for (long long k = 0; k < static_cast<long long>(eclipseCase->mainGrid()->cells().size()); k++)
{
RigCell& cell = eclipseCase->mainGrid()->cells()[k];
{
double val = offsetValue + scaleValue * ( (stepIndex * 1000 + k) % eclipseCase->mainGrid()->cells().size() );
values->push_back(val);
values->at(k) = val;
}
}
@ -521,3 +529,11 @@ void RigReservoirBuilderMock::addFaults(RigCaseData* eclipseCase)
grid->setFaults(faults);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirBuilderMock::enableWellData(bool enableWellData)
{
m_enableWellData = false;
}

View File

@ -48,6 +48,7 @@ public:
void setWorldCoordinates(cvf::Vec3d minWorldCoordinate, cvf::Vec3d maxWorldCoordinate);
void setGridPointDimensions(const cvf::Vec3st& gridPointDimensions);
void setResultInfo(size_t resultCount, size_t timeStepCount);
void enableWellData(bool enableWellData);
size_t resultCount() const { return m_resultCount; }
size_t timeStepCount() const { return m_timeStepCount; }
@ -91,6 +92,7 @@ private:
cvf::Vec3st m_gridPointDimensions;
size_t m_resultCount;
size_t m_timeStepCount;
bool m_enableWellData;
std::vector<LocalGridRefinement> m_localGridRefinements;
};

View File

@ -16,9 +16,12 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiaStdInclude.h"
#include "RiaSocketCommand.h"
#include "RiaSocketServer.h"
#include "RiaSocketTools.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RimReservoirView.h"
#include "RimResultSlot.h"
@ -28,8 +31,8 @@
#include "RimWellCollection.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimReservoirCellResultsCacher.h"
#include "RimCase.h"
#include "RigCaseData.h"
#include "RigCaseCellResultsData.h"
@ -37,6 +40,7 @@
//--------------------------------------------------------------------------------------------------
/// OBSOLETE, to be deleted
//--------------------------------------------------------------------------------------------------
@ -128,18 +132,9 @@ public:
quint64 timestepByteCount = (quint64)(timestepResultCount*sizeof(qint32));
socketStream << timestepByteCount;
// Then write the data.
for (size_t tIdx = 0; tIdx < columnCount; ++tIdx)
{
#if 1 // Write data as raw bytes, fast but does not handle byteswapping
server->currentClient()->write((const char *)activeCellInfo[tIdx].data(), timestepByteCount);
#else // Write data using QDataStream, does byteswapping for us. Must use QDataStream on client as well
for (size_t cIdx = 0; cIdx < activeCellInfo[tIdx].size(); ++cIdx)
{
socketStream << activeCellInfo[tIdx][cIdx];
}
#endif
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)activeCellInfo[tIdx].data(), timestepByteCount);
}
return true;

View File

@ -34,6 +34,9 @@
#include "RigCaseCellResultsData.h"
#include <QTcpSocket>
#include "RiaApplication.h"
#include "RiaPreferences.h"
//--------------------------------------------------------------------------------------------------
@ -84,11 +87,14 @@ public:
// dv(2) = cellCountK;
// dv(3) = 3;
std::vector<double> cellCenterValues(doubleValueCount);
cvf::Vec3d cornerVerts[8];
quint64 coordCount = 0;
size_t blockByteCount = cellCount * sizeof(double);
std::vector<double> doubleValues(blockByteCount);
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
{
quint64 valueIndex = 0;
for (size_t k = 0; k < cellCountK; k++)
{
for (size_t j = 0; j < cellCountJ; j++)
@ -98,16 +104,16 @@ public:
size_t localCellIdx = rigGrid->cellIndexFromIJK(i, j, k);
cvf::Vec3d center = rigGrid->cell(localCellIdx).center();
cellCenterValues[coordCount++] = center[coordIdx];
doubleValues[valueIndex++] = center[coordIdx];
}
}
}
CVF_ASSERT(valueIndex == cellCount);
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)doubleValues.data(), blockByteCount);
}
CVF_ASSERT(coordCount == doubleValueCount);
server->currentClient()->write((const char *)cellCenterValues.data(), byteCount);
return true;
}
};
@ -149,6 +155,11 @@ public:
size_t activeCellCount = actCellInfo->globalActiveCellCount();
size_t doubleValueCount = activeCellCount * 3;
socketStream << (quint64)activeCellCount;
quint64 byteCount = doubleValueCount * sizeof(double);
socketStream << byteCount;
// This structure is supposed to be received by Octave using a NDArray. The ordering of this loop is
// defined by the ordering of the receiving NDArray
//
@ -159,28 +170,26 @@ public:
// dv(0) = coordCount;
// dv(1) = 3;
std::vector<double> cellCenterValues(doubleValueCount);
quint64 coordCount = 0;
size_t blockByteCount = activeCellCount * sizeof(double);
std::vector<double> doubleValues(blockByteCount);
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
{
quint64 valueIndex = 0;
for (size_t globalCellIdx = 0; globalCellIdx < mainGrid->cells().size(); globalCellIdx++)
{
if (!actCellInfo->isActive(globalCellIdx)) continue;
cvf::Vec3d center = mainGrid->cells()[globalCellIdx].center();
cellCenterValues[coordCount++] = center[coordIdx];
doubleValues[valueIndex++] = center[coordIdx];
}
CVF_ASSERT(valueIndex == activeCellCount);
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)doubleValues.data(), blockByteCount);
}
CVF_ASSERT(coordCount == doubleValueCount);
socketStream << (quint64)activeCellCount;
quint64 byteCount = doubleValueCount * sizeof(double);
socketStream << byteCount;
server->currentClient()->write((const char *)cellCenterValues.data(), byteCount);
return true;
}
@ -241,15 +250,18 @@ public:
// dv(3) = 8;
// dv(4) = 3;
std::vector<double> cellCornerValues(doubleValueCount);
cvf::Vec3d cornerVerts[8];
quint64 coordCount = 0;
size_t blockByteCount = cellCount * sizeof(double);
std::vector<double> doubleValues(blockByteCount);
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
{
for (size_t cornerIdx = 0; cornerIdx < 8; cornerIdx++)
{
size_t cornerIndexMapping = cellCornerMappingEclipse[cornerIdx];
quint64 valueIndex = 0;
for (size_t k = 0; k < cellCountK; k++)
{
for (size_t j = 0; j < cellCountJ; j++)
@ -259,15 +271,17 @@ public:
size_t localCellIdx = rigGrid->cellIndexFromIJK(i, j, k);
rigGrid->cellCornerVertices(localCellIdx, cornerVerts);
cellCornerValues[coordCount++] = cornerVerts[cornerIndexMapping][coordIdx];
doubleValues[valueIndex++] = cornerVerts[cornerIndexMapping][coordIdx];
}
}
}
CVF_ASSERT(valueIndex == cellCount);
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)doubleValues.data(), blockByteCount);
}
}
server->currentClient()->write((const char *)cellCornerValues.data(), byteCount);
return true;
}
};
@ -310,6 +324,10 @@ public:
size_t activeCellCount = actCellInfo->globalActiveCellCount();
size_t doubleValueCount = activeCellCount * 3 * 8;
socketStream << (quint64)activeCellCount;
quint64 byteCount = doubleValueCount * sizeof(double);
socketStream << byteCount;
// This structure is supposed to be received by Octave using a NDArray. The ordering of this loop is
// defined by the ordering of the receiving NDArray
//
@ -321,32 +339,33 @@ public:
// dv(1) = 8;
// dv(2) = 3;
std::vector<double> cellCornerValues(doubleValueCount);
cvf::Vec3d cornerVerts[8];
quint64 coordCount = 0;
size_t blockByteCount = activeCellCount * sizeof(double);
std::vector<double> doubleValues(blockByteCount);
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
{
for (size_t cornerIdx = 0; cornerIdx < 8; cornerIdx++)
{
size_t cornerIndexMapping = cellCornerMappingEclipse[cornerIdx];
quint64 valueIndex = 0;
for (size_t globalCellIdx = 0; globalCellIdx < mainGrid->cells().size(); globalCellIdx++)
{
if (!actCellInfo->isActive(globalCellIdx)) continue;
mainGrid->cellCornerVertices(globalCellIdx, cornerVerts);
cellCornerValues[coordCount++] = cornerVerts[cornerIndexMapping][coordIdx];
doubleValues[valueIndex++] = cornerVerts[cornerIndexMapping][coordIdx];
}
CVF_ASSERT(valueIndex == activeCellCount);
RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)doubleValues.data(), blockByteCount);
}
}
socketStream << (quint64)activeCellCount;
quint64 byteCount = doubleValueCount * sizeof(double);
socketStream << byteCount;
server->currentClient()->write((const char *)cellCornerValues.data(), byteCount);
return true;
}

View File

@ -40,6 +40,9 @@
#include "Rim3dOverlayInfoConfig.h"
#include <QTcpSocket>
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RiaSocketDataTransfer.h"
//--------------------------------------------------------------------------------------------------
@ -143,6 +146,9 @@ public:
socketStream << timestepByteCount ;
// Then write the data.
size_t valueCount = RiaSocketDataTransfer::maximumValueCountInBlock();
std::vector<double> values(valueCount);
size_t valueIndex = 0;
size_t globalCellCount = activeInfo->globalCellCount();
for (size_t tIdx = 0; tIdx < requestedTimesteps.size(); ++tIdx)
@ -154,37 +160,34 @@ public:
{
if (resultIdx < scalarResultFrames->at(requestedTimesteps[tIdx]).size())
{
socketStream << scalarResultFrames->at(requestedTimesteps[tIdx])[resultIdx];
values[valueIndex] = scalarResultFrames->at(requestedTimesteps[tIdx])[resultIdx];
}
else
{
socketStream << HUGE_VAL;
values[valueIndex] = HUGE_VAL;
}
valueIndex++;
if (valueIndex >= valueCount)
{
if (!RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)values.data(), valueIndex * sizeof(double)))
{
return false;
}
valueIndex = 0;
}
}
}
}
#if 0
// This aproach is faster but does not handle coarsening
size_t timestepResultCount = scalarResultFrames->front().size();
quint64 timestepByteCount = (quint64)(timestepResultCount*sizeof(double));
socketStream << timestepByteCount ;
// Then write the data.
for (size_t tIdx = 0; tIdx < requestedTimesteps.size(); ++tIdx)
// Write remaining data
if (!RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)values.data(), valueIndex * sizeof(double)))
{
#if 1 // Write data as raw bytes, fast but does not handle byteswapping
server->currentClient()->write((const char *)scalarResultFrames->at(requestedTimesteps[tIdx]).data(), timestepByteCount); // Raw print of data. Fast but no platform conversion
#else // Write data using QDataStream, does byteswapping for us. Must use QDataStream on client as well
for (size_t cIdx = 0; cIdx < scalarResultFrames->at(requestedTimesteps[tIdx]).size(); ++cIdx)
{
socketStream << scalarResultFrames->at(tIdx)[cIdx];
}
#endif
return false;
}
#endif
}
}
return true;
}
};
@ -304,10 +307,6 @@ public:
quint64 timestepCount = (quint64)requestedTimesteps.size();
socketStream << timestepCount;
size_t doubleValueCount = cellCountI * cellCountJ * cellCountK * timestepCount * sizeof(double);
std::vector<double> values(doubleValueCount);
size_t valueIdx = 0;
for (size_t tsIdx = 0; tsIdx < timestepCount; tsIdx++)
{
cvf::ref<cvf::StructGridScalarDataAccess> cellCenterDataAccessObject = rimCase->reservoirData()->dataAccessObject(rigGrid, porosityModelEnum, requestedTimesteps[tsIdx], scalarResultIndex);
@ -316,6 +315,9 @@ public:
continue;
}
size_t valueCount = RiaSocketDataTransfer::maximumValueCountInBlock();
std::vector<double> values(valueCount);
size_t valueIndex = 0;
for (size_t cellIdx = 0; cellIdx < rigGrid->cellCount(); cellIdx++)
{
double cellValue = cellCenterDataAccessObject->cellScalar(cellIdx);
@ -323,12 +325,26 @@ public:
{
cellValue = 0.0;
}
values[valueIdx++] = cellValue;
values[valueIndex++] = cellValue;
if (valueIndex >= valueCount)
{
if (!RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)values.data(), valueIndex * sizeof(double)))
{
return false;
}
valueIndex = 0;
}
}
// Write remaining data
if (!RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)values.data(), valueIndex * sizeof(double)))
{
return false;
}
}
server->currentClient()->write((const char *)values.data(), doubleValueCount);
return true;
}
};
@ -553,16 +569,18 @@ public:
internalMatrixData = m_scalarResultsToAdd->at(m_requestedTimesteps[m_currentTimeStepNumberToRead]).data();
}
#if 1 // Use raw data transfer. Faster.
bytesRead = currentClient->read((char*)(internalMatrixData), m_bytesPerTimeStepToRead);
#else
for (size_t cIdx = 0; cIdx < cellCountFromOctave; ++cIdx)
QStringList errorMessages;
if (!RiaSocketDataTransfer::readBlockDataFromSocket(currentClient, (char*)(internalMatrixData), m_bytesPerTimeStepToRead, errorMessages))
{
socketStream >> internalMatrixData[cIdx];
for (int i = 0; i < errorMessages.size(); i++)
{
server->errorMessageDialog()->showMessage(errorMessages[i]);
}
if (socketStream.status() == QDataStream::Ok) bytesRead += sizeof(double);
currentClient->abort();
return true;
}
#endif
// Map data from active to result index based container ( Coarsening is active)
if (isCoarseningActive)
{
@ -577,12 +595,6 @@ public:
}
}
if ((int)m_bytesPerTimeStepToRead != bytesRead)
{
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") +
RiaSocketServer::tr("Could not read binary double data properly from socket"));
}
++m_currentTimeStepNumberToRead;
}
@ -897,8 +909,17 @@ public:
std::vector<double> doubleValues(cellCountFromOctave);
qint64 bytesRead = currentClient->read((char*)(doubleValues.data()), m_bytesPerTimeStepToRead);
size_t doubleValueIndex = 0;
QStringList errorMessages;
if (!RiaSocketDataTransfer::readBlockDataFromSocket(currentClient, (char*)(doubleValues.data()), m_bytesPerTimeStepToRead, errorMessages))
{
for (int i = 0; i < errorMessages.size(); i++)
{
server->errorMessageDialog()->showMessage(errorMessages[i]);
}
currentClient->abort();
return true;
}
cvf::ref<cvf::StructGridScalarDataAccess> cellCenterDataAccessObject =
m_currentReservoir->reservoirData()->dataAccessObject(grid, m_porosityModelEnum, m_requestedTimesteps[m_currentTimeStepNumberToRead], m_currentScalarIndex);

View File

@ -0,0 +1,113 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA, Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaSocketDataTransfer.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaSocketDataTransfer::writeBlockDataToSocket(QTcpSocket* socket, const char* data, quint64 bytesToWrite, QStringList& errorMessages)
{
quint64 bytesWritten = 0;
int blockCount = 0;
quint64 maxBlockSize = maximumValueCountInBlock() * sizeof(double);
while (bytesWritten < bytesToWrite)
{
quint64 byteCountToWrite = qMin(bytesToWrite - bytesWritten, maxBlockSize);
qint64 actuallyBytesWritten = socket->write(data + bytesWritten, byteCountToWrite);
if (actuallyBytesWritten < 0)
{
errorMessages.push_back("Error detected when writing data, error string from socket");
errorMessages.push_back(socket->errorString());
return false;
}
bytesWritten += actuallyBytesWritten;
blockCount++;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaSocketDataTransfer::readBlockDataFromSocket(QTcpSocket* socket, char* data, quint64 bytesToRead, QStringList& errorMessages)
{
quint64 bytesRead = 0;
quint64 maxBlockSize = maximumValueCountInBlock() * sizeof(double);
while (bytesRead < bytesToRead)
{
if (socket->bytesAvailable())
{
quint64 byteCountToRead = bytesToRead - bytesRead;
byteCountToRead = qMin(byteCountToRead, maxBlockSize);
qint64 actuallyBytesRead = socket->read(data + bytesRead, byteCountToRead);
if (actuallyBytesRead < 0)
{
errorMessages.push_back("Error detected when reading data, error string from socket");
errorMessages.push_back(socket->errorString());
return false;
}
bytesRead += actuallyBytesRead;
#ifdef octave_oct_h
//octave_stdout << "Byte read " << bytesRead << " of a total of "<< bytesToRead << "\n";
#endif
}
else
{
if (!socket->waitForReadyRead())
{
errorMessages.push_back("Waited for data for %1 milli seconds.");
errorMessages.push_back(socket->errorString());
return false;
}
}
// Allow Octave process to end a long running Octave function
#ifdef octave_oct_h
OCTAVE_QUIT;
#endif
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RiaSocketDataTransfer::maximumValueCountInBlock()
{
return 20000;
}

View File

@ -0,0 +1,36 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA, Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include <QTcpSocket>
#include <QStringList>
//==================================================================================================
/// Utility class used for transfer of data using QTcpSocket
///
/// As the compile configuration for octave plugins is quite complex,
// the octave plugins includes the cpp-file to be able to compile only one file per plugin
//==================================================================================================
class RiaSocketDataTransfer
{
public:
static size_t maximumValueCountInBlock();
public:
static bool writeBlockDataToSocket(QTcpSocket* socket, const char* data, quint64 bytesToWrite, QStringList& errorMessages);
static bool readBlockDataFromSocket(QTcpSocket* socket, char* data, quint64 bytesToRead, QStringList& errorMessages);
};

View File

@ -16,6 +16,10 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiaStdInclude.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RiaSocketTools.h"
#include "RiaSocketServer.h"
#include "RimCase.h"
@ -34,6 +38,9 @@
#include "RimInputPropertyCollection.h"
#include "RiaSocketDataTransfer.h"
#include <QTcpSocket>
//--------------------------------------------------------------------------------------------------
///
@ -98,4 +105,28 @@ void RiaSocketTools::getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QStri
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaSocketTools::writeBlockData(RiaSocketServer* server, QTcpSocket* socket, const char* data, quint64 bytesToWrite)
{
cvf::Timer timer;
QStringList errorMessages;
bool writeSucceded = RiaSocketDataTransfer::writeBlockDataToSocket(socket, data, bytesToWrite, errorMessages);
if (server)
{
for (int i = 0; i < errorMessages.size(); i++)
{
server->errorMessageDialog()->showMessage(errorMessages[i]);
}
// double totalTimeMS = timer.time() * 1000.0;
// QString resultInfo = QString("Total time '%1 ms'").arg(totalTimeMS);
//
// server->errorMessageDialog()->showMessage(resultInfo);
}
return writeSucceded;
}

View File

@ -17,6 +17,7 @@
class RimCase;
class RiaSocketServer;
class QTcpSocket;
#define PMonLog( MessageString ) RiuMainWindow::instance()->processMonitor()->addStringToLog( MessageString );
@ -25,4 +26,6 @@ class RiaSocketTools
public:
static RimCase* findCaseFromArgs(RiaSocketServer* server, const QList<QByteArray>& args);
static void getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId);
static bool writeBlockData(RiaSocketServer* server, QTcpSocket* socket, const char* data, quint64 bytesToWrite);
};

View File

@ -43,7 +43,6 @@
#include "RiuMultiCaseImportDialog.h"
#include "RiaPreferences.h"
#include "RiuPreferencesDialog.h"
#include "RigCaseCellResultsData.h"
@ -63,6 +62,7 @@
#include "RimCalcScript.h"
#include "RimTools.h"
#include "RiaRegressionTest.h"
#include "cafPdmUiPropertyDialog.h"
@ -199,6 +199,7 @@ void RiuMainWindow::createActions()
m_mockModelAction = new QAction("&Mock Model", this);
m_mockResultsModelAction = new QAction("Mock Model With &Results", this);
m_mockLargeResultsModelAction = new QAction("Large Mock Model", this);
m_mockModelCustomizedAction = new QAction("Customized Mock Model", this);
m_mockInputModelAction = new QAction("Input Mock Model", this);
m_snapshotToFile = new QAction(QIcon(":/SnapShotSave.png"), "Snapshot To File", this);
@ -226,6 +227,7 @@ void RiuMainWindow::createActions()
connect(m_mockModelAction, SIGNAL(triggered()), SLOT(slotMockModel()));
connect(m_mockResultsModelAction, SIGNAL(triggered()), SLOT(slotMockResultsModel()));
connect(m_mockLargeResultsModelAction, SIGNAL(triggered()), SLOT(slotMockLargeResultsModel()));
connect(m_mockModelCustomizedAction, SIGNAL(triggered()), SLOT(slotMockModelCustomized()));
connect(m_mockInputModelAction, SIGNAL(triggered()), SLOT(slotInputMockModel()));
connect(m_snapshotToFile, SIGNAL(triggered()), SLOT(slotSnapshotToFile()));
@ -386,6 +388,7 @@ void RiuMainWindow::createMenus()
testMenu->addAction(m_mockModelAction);
testMenu->addAction(m_mockResultsModelAction);
testMenu->addAction(m_mockLargeResultsModelAction);
testMenu->addAction(m_mockModelCustomizedAction);
testMenu->addAction(m_mockInputModelAction);
testMenu->addSeparator();
testMenu->addAction(m_createCommandObject);
@ -846,8 +849,6 @@ void RiuMainWindow::slotMockModel()
{
RiaApplication* app = RiaApplication::instance();
app->createMockModel();
//m_mainViewer->setDefaultView();
}
//--------------------------------------------------------------------------------------------------
@ -857,8 +858,6 @@ void RiuMainWindow::slotMockResultsModel()
{
RiaApplication* app = RiaApplication::instance();
app->createResultsMockModel();
//m_mainViewer->setDefaultView();
}
@ -871,6 +870,14 @@ void RiuMainWindow::slotMockLargeResultsModel()
app->createLargeResultsMockModel();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::slotMockModelCustomized()
{
RiaApplication* app = RiaApplication::instance();
app->createMockModelCustomized();
}
//--------------------------------------------------------------------------------------------------
///
@ -1217,8 +1224,8 @@ void RiuMainWindow::slotShowPerformanceInfo(bool enable)
void RiuMainWindow::slotEditPreferences()
{
RiaApplication* app = RiaApplication::instance();
RiuPreferencesDialog preferencesDialog(this, app->preferences(), "Preferences");
if (preferencesDialog.exec() == QDialog::Accepted)
caf::PdmUiPropertyDialog propertyDialog(this, app->preferences(), "Preferences");
if (propertyDialog.exec() == QDialog::Accepted)
{
// Write preferences using QSettings and apply them to the application
app->writeFieldsToApplicationStore(app->preferences());
@ -1447,9 +1454,9 @@ void RiuMainWindow::slotOpenMultipleCases()
if (1)
{
gridFileNames += "Result Mock Debug Model With Results";
gridFileNames += "Result Mock Debug Model With Results";
gridFileNames += "Result Mock Debug Model With Results";
gridFileNames += RimDefines::mockModelBasicWithResults();
gridFileNames += RimDefines::mockModelBasicWithResults();
gridFileNames += RimDefines::mockModelBasicWithResults();
}
else
{
@ -1766,7 +1773,7 @@ void RiuMainWindow::slotShowRegressionTestDialog()
RiaApplication* app = RiaApplication::instance();
app->readFieldsFromApplicationStore(&regTestConfig);
RiuPreferencesDialog regressionTestDialog(this, &regTestConfig, "Regression Test");
caf::PdmUiPropertyDialog regressionTestDialog(this, &regTestConfig, "Regression Test");
if (regressionTestDialog.exec() == QDialog::Accepted)
{
// Write preferences using QSettings and apply them to the application

View File

@ -154,6 +154,7 @@ private:
QAction* m_mockModelAction;
QAction* m_mockResultsModelAction;
QAction* m_mockLargeResultsModelAction;
QAction* m_mockModelCustomizedAction;
QAction* m_mockInputModelAction;
QAction* m_snapshotToFile;
@ -243,6 +244,7 @@ private slots:
void slotMockModel();
void slotMockResultsModel();
void slotMockLargeResultsModel();
void slotMockModelCustomized();
void slotInputMockModel();
// Windows slots

View File

@ -1,67 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaStdInclude.h"
#include "RiuPreferencesDialog.h"
#include "cafAppEnum.h"
#include "cafPdmObject.h"
#include "RimUiTreeModelPdm.h"
#include "cafPdmUiPropertyView.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPreferencesDialog::RiuPreferencesDialog(QWidget* parent, caf::PdmObject* object, const QString& windowTitle)
: QDialog(parent)
{
CVF_ASSERT(object);
m_pdmObject = object;
m_windowTitle = windowTitle;
setupUi();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPreferencesDialog::setupUi()
{
setWindowTitle(m_windowTitle);
m_pdmUiPropertyView = new caf::PdmUiPropertyView(this);
QVBoxLayout* dialogLayout = new QVBoxLayout;
setLayout(dialogLayout);
dialogLayout->addWidget(m_pdmUiPropertyView);
m_pdmUiPropertyView->showProperties(m_pdmObject);
// Buttons
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
dialogLayout->addWidget(buttonBox);
this->resize(400, 200);
}

View File

@ -11,6 +11,7 @@ set( QOBJECT_HEADERS
cafUiTreeModelPdm.h
cafUiProcess.h
cafPdmSettings.h
cafPdmUiLineEditor.h
cafPdmUiCheckBoxEditor.h
cafPdmUiComboBoxEditor.h
@ -24,6 +25,7 @@ set( QOBJECT_HEADERS
cafPdmUiColorEditor.h
cafPdmUiPropertyView.h
cafPdmUiPropertyDialog.h
cafPdmUiTreeView.h
cafPdmUiTreeViewModel.h
cafPdmUiListView.h
@ -38,6 +40,7 @@ endif()
add_library( ${PROJECT_NAME}
cafAboutDialog.cpp
cafAboutDialog.h
cafPdmSettings.cpp
cafPdmUiCheckBoxEditor.cpp
cafPdmUiCheckBoxEditor.h
cafPdmUiColorEditor.cpp
@ -57,6 +60,8 @@ add_library( ${PROJECT_NAME}
cafPdmUiListViewEditor.cpp
cafPdmUiListViewEditor.h
cafPdmUiListView.cpp
cafPdmUiPropertyDialog.cpp
cafPdmUiPropertyDialog.h
cafPdmUiPropertyView.cpp
cafPdmUiPropertyView.h
cafPdmUiPushButtonEditor.cpp

View File

@ -0,0 +1,116 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cafPdmSettings.h"
#include "cafPdmField.h"
#include <assert.h>
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Settings::readFieldsFromApplicationStore(caf::PdmObject* object)
{
// Qt doc :
//
// Constructs a QSettings object for accessing settings of the application and organization
// set previously with a call to QCoreApplication::setOrganizationName(),
// QCoreApplication::setOrganizationDomain(), and QCoreApplication::setApplicationName().
QSettings settings;
QString prefix = object->classKeyword();
if (!prefix.isEmpty())
{
prefix += "/";
}
std::vector<caf::PdmFieldHandle*> fields;
object->fields(fields);
size_t i;
for (i = 0; i < fields.size(); i++)
{
caf::PdmFieldHandle* fieldHandle = fields[i];
QString keywordWithPrefix = prefix + fieldHandle->keyword();
if (settings.contains(keywordWithPrefix))
{
QVariant val = settings.value(keywordWithPrefix);
fieldHandle->setValueFromUi(val);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Settings::writeFieldsToApplicationStore(caf::PdmObject* object)
{
assert(object);
// Qt doc :
//
// Constructs a QSettings object for accessing settings of the application and organization
// set previously with a call to QCoreApplication::setOrganizationName(),
// QCoreApplication::setOrganizationDomain(), and QCoreApplication::setApplicationName().
QSettings settings;
QString prefix = object->classKeyword();
if (!prefix.isEmpty())
{
prefix += "/";
}
std::vector<caf::PdmFieldHandle*> fields;
object->fields(fields);
size_t i;
for (i = 0; i < fields.size(); i++)
{
caf::PdmFieldHandle* fieldHandle = fields[i];
QString keywordWithPrefix = prefix + fieldHandle->keyword();
settings.setValue(keywordWithPrefix, fieldHandle->uiValue());
}
}
} // namespace caf

View File

@ -0,0 +1,55 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include <QSettings>
namespace caf
{
class PdmObject;
class Settings
{
public:
static void readFieldsFromApplicationStore(caf::PdmObject* object);
static void writeFieldsToApplicationStore(caf::PdmObject* object);
};
} // end namespace caf

View File

@ -65,10 +65,11 @@ CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiLineEditor, QString);
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiLineEditor, int);
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiLineEditor, double);
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiLineEditor, float);
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiLineEditor, quint64);
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiListEditor, std::vector<QString>);
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiListEditor, std::vector<int>);
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiListEditor, std::vector<unsigned int>);
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiListEditor, std::vector<float>);

View File

@ -0,0 +1,92 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cafPdmUiPropertyDialog.h"
#include "cafPdmObject.h"
#include "cafPdmUiPropertyView.h"
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <assert.h>
namespace caf {
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUiPropertyDialog::PdmUiPropertyDialog(QWidget* parent, caf::PdmObject* object, const QString& windowTitle)
: QDialog(parent)
{
assert(object);
m_pdmObject = object;
m_windowTitle = windowTitle;
setupUi();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiPropertyDialog::setupUi()
{
setWindowTitle(m_windowTitle);
m_pdmUiPropertyView = new caf::PdmUiPropertyView(this);
QVBoxLayout* dialogLayout = new QVBoxLayout;
setLayout(dialogLayout);
dialogLayout->addWidget(m_pdmUiPropertyView);
m_pdmUiPropertyView->showProperties(m_pdmObject);
// Buttons
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
dialogLayout->addWidget(buttonBox);
this->resize(400, 200);
}
} // end namespace caf

View File

@ -0,0 +1,70 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include <QDialog>
namespace caf
{
class PdmObject;
class PdmUiPropertyView;
//==================================================================================================
//
//
//
//==================================================================================================
class PdmUiPropertyDialog : public QDialog
{
Q_OBJECT
public:
PdmUiPropertyDialog(QWidget* parent, caf::PdmObject* object, const QString& windowTitle);
private:
void setupUi();
private:
QString m_windowTitle;
caf::PdmObject* m_pdmObject;
caf::PdmUiPropertyView* m_pdmUiPropertyView;
};
} // end namespace caf

View File

@ -4,28 +4,28 @@
# See http://www.cmake.org/Wiki/CMakeUserFindOctave
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
riGetGridProperty.cpp
riSetGridProperty.cpp
riGetPropertyNames.cpp
riGetWellNames.cpp
riGetWellStatus.cpp
riGetWellCells.cpp
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
riGetGridProperty.cpp
riSetGridProperty.cpp
riGetPropertyNames.cpp
riGetWellNames.cpp
riGetWellStatus.cpp
riGetWellCells.cpp
)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
@ -88,7 +88,7 @@ if (RESINSIGHT_OCTAVE_PLUGIN_QMAKE AND RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE)
OUTPUT "${octFileName}"
COMMAND call "\"%VS100COMNTOOLS%../../VC/vcvarsall.bat\"" x86
COMMAND ${CMAKE_COMMAND} ARGS -E chdir ${RESINSIGHT_OCTAVE_BIN_DIR} ${RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE} -I${OCTAVE_QT_QTNETWORK_INCLUDE_DIR}
-I${OCTAVE_QT_QTCORE_INCLUDE_DIR} -I${OCTAVE_QT_INCLUDE_DIR} ${RPATH_COMMAND}
-I${OCTAVE_QT_QTCORE_INCLUDE_DIR} -I${OCTAVE_QT_INCLUDE_DIR} -I${ResInsight_SOURCE_DIR}/ApplicationCode/SocketInterface ${RPATH_COMMAND}
-L${OCTAVE_QT_LIBRARY_DIR} -lQtCore${QT_LIBRARY_POSTFIX} -lQtNetwork${QT_LIBRARY_POSTFIX} -o "${octFileName}" "${srcFileName}"
DEPENDS "${srcFileName}"
COMMENT "===> 32-bit x86 VS2010 : Generating ${octFileName}"
@ -97,7 +97,7 @@ if (RESINSIGHT_OCTAVE_PLUGIN_QMAKE AND RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE)
add_custom_command(
OUTPUT "${octFileName}"
COMMAND ${CMAKE_COMMAND} ARGS -E chdir ${RESINSIGHT_OCTAVE_BIN_DIR} ${RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE} -I${OCTAVE_QT_QTNETWORK_INCLUDE_DIR}
-I${OCTAVE_QT_QTCORE_INCLUDE_DIR} -I${OCTAVE_QT_INCLUDE_DIR} ${RPATH_COMMAND}
-I${OCTAVE_QT_QTCORE_INCLUDE_DIR} -I${OCTAVE_QT_INCLUDE_DIR} -I${ResInsight_SOURCE_DIR}/ApplicationCode/SocketInterface ${RPATH_COMMAND}
-L${OCTAVE_QT_LIBRARY_DIR} -lQtCore${QT_LIBRARY_POSTFIX} -lQtNetwork${QT_LIBRARY_POSTFIX} -o "${octFileName}" "${srcFileName}"
DEPENDS "${srcFileName}"
COMMENT "===> Generating ${octFileName}"
@ -107,7 +107,7 @@ if (RESINSIGHT_OCTAVE_PLUGIN_QMAKE AND RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE)
add_custom_command(
OUTPUT "${octFileName}"
COMMAND OCTAVE_HOME=${OCTAVE_HOME} ${RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE}
-I${OCTAVE_QT_QTNETWORK_INCLUDE_DIR} -I${OCTAVE_QT_QTCORE_INCLUDE_DIR} -I${OCTAVE_QT_INCLUDE_DIR} ${RPATH_COMMAND}
-I${OCTAVE_QT_QTNETWORK_INCLUDE_DIR} -I${OCTAVE_QT_QTCORE_INCLUDE_DIR} -I${OCTAVE_QT_INCLUDE_DIR} -I${ResInsight_SOURCE_DIR}/ApplicationCode/SocketInterface ${RPATH_COMMAND}
-L${OCTAVE_QT_LIBRARY_DIR} -lQtCore -lQtNetwork -o "${octFileName}" "${srcFileName}"
DEPENDS "${srcFileName}"
COMMENT "===> Generating ${octFileName}"
@ -141,7 +141,9 @@ if (RESINSIGHT_OCTAVE_PLUGIN_QMAKE AND RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE)
"${CMAKE_CURRENT_BINARY_DIR}/riGetWellNames.oct"
"${CMAKE_CURRENT_BINARY_DIR}/riGetWellStatus.oct"
"${CMAKE_CURRENT_BINARY_DIR}/riGetWellCells.oct"
SOURCES ${CPP_SOURCES}
SOURCES
${CPP_SOURCES}
riSettings.h
)

View File

@ -1,7 +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 getActiveCellCenters(NDArray& cellCenterValues, const QString &hostName, quint16 port, const qint32& caseId, const QString& porosityModel)
@ -61,24 +64,17 @@ void getActiveCellCenters(NDArray& cellCenterValues, const QString &hostName, qu
cellCenterValues.resize(dv);
while (socket.bytesAvailable() < (qint64)(byteCount))
{
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;
}
OCTAVE_QUIT;
}
quint64 bytesRead = 0;
double* internalMatrixData = cellCenterValues.fortran_vec();
bytesRead = socket.read((char*)(internalMatrixData), byteCount);
QStringList errorMessages;
if (byteCount != bytesRead)
if (!RiaSocketDataTransfer::readBlockDataFromSocket(&socket, (char*)(internalMatrixData), byteCount, errorMessages))
{
error("Could not read binary double data properly from socket");
octave_stdout << "Active cell count: " << activeCellCount << std::endl;
for (int i = 0; i < errorMessages.size(); i++)
{
error(errorMessages[i].toLatin1().data());
}
OCTAVE_QUIT;
}
return;

View File

@ -1,7 +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 getActiveCellCorners(NDArray& cellCornerValues, const QString &hostName, quint16 port, const qint32& caseId, const QString& porosityModel)
@ -61,24 +64,16 @@ void getActiveCellCorners(NDArray& cellCornerValues, const QString &hostName, qu
dv(2) = 3;
cellCornerValues.resize(dv);
while (socket.bytesAvailable() < (qint64)(byteCount))
{
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;
}
OCTAVE_QUIT;
}
quint64 bytesRead = 0;
double* internalMatrixData = cellCornerValues.fortran_vec();
bytesRead = socket.read((char*)(internalMatrixData), byteCount);
if (byteCount != bytesRead)
QStringList errorMessages;
if (!RiaSocketDataTransfer::readBlockDataFromSocket(&socket, (char*)(internalMatrixData), byteCount, errorMessages))
{
error("Could not read binary double data properly from socket");
octave_stdout << "Active cell count: " << activeCellCount << std::endl;
for (int i = 0; i < errorMessages.size(); i++)
{
error(errorMessages[i].toLatin1().data());
}
OCTAVE_QUIT;
}
return;

View File

@ -1,8 +1,9 @@
#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 getActiveCellInfo(int32NDArray& activeCellInfo, const QString &hostName, quint16 port, const qint64& caseId, const QString& porosityModel)
{
@ -43,59 +44,32 @@ void getActiveCellInfo(int32NDArray& activeCellInfo, const QString &hostName, qu
// Read timestep count and blocksize
quint64 columnCount;
quint64 byteCount;
quint64 byteCountForOneTimestep;
size_t activeCellCount;
socketStream >> columnCount;
socketStream >> byteCount;
socketStream >> byteCountForOneTimestep;
activeCellCount = byteCount / sizeof(qint32);
activeCellCount = byteCountForOneTimestep / sizeof(qint32);
dim_vector dv (2, 1);
dv(0) = activeCellCount;
dv(1) = columnCount;
activeCellInfo.resize(dv);
if (!(byteCount && columnCount))
if (!(byteCountForOneTimestep && columnCount))
{
error ("Could not find the requested data in ResInsight");
return;
}
// Wait for available data for each column, then read data for each column
for (size_t tIdx = 0; tIdx < columnCount; ++tIdx)
qint32* internalMatrixData = (qint32*)activeCellInfo.fortran_vec()->mex_get_data();
QStringList errorMessages;
if (!RiaSocketDataTransfer::readBlockDataFromSocket(&socket, (char*)(internalMatrixData), columnCount * byteCountForOneTimestep, errorMessages))
{
while (socket.bytesAvailable() < (int)byteCount)
for (int i = 0; i < errorMessages.size(); i++)
{
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
{
QString errorMsg = QString("Waiting for column number: %1 of %2: %3").arg(tIdx).arg(columnCount).arg(socket.errorString());
error(errorMsg.toLatin1().data());
octave_stdout << "Active cells: " << activeCellCount << ", Columns: " << columnCount << std::endl;
return ;
}
OCTAVE_QUIT;
}
qint64 bytesRead = 0;
qint32* internalMatrixData = (qint32*)activeCellInfo.fortran_vec()->mex_get_data();
#if 1 // Use raw data transfer. Faster.
bytesRead = socket.read((char*)(internalMatrixData + tIdx * activeCellCount), byteCount);
#else
for (size_t cIdx = 0; cIdx < activeCellCount; ++cIdx)
{
socketStream >> internalMatrixData[tIdx * activeCellCount + cIdx];
if (socketStream.status() == QDataStream::Ok) bytesRead += sizeof(int);
}
#endif
if ((int)byteCount != bytesRead)
{
error("Could not read binary double data properly from socket");
octave_stdout << "Active cells: " << activeCellCount << ", Columns: " << columnCount << std::endl;
error(errorMessages[i].toLatin1().data());
}
OCTAVE_QUIT;

View File

@ -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() < (int)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 ((int)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);

View File

@ -1,7 +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 getCellCenters(NDArray& cellCenterValues, const QString &hostName, quint16 port, const qint32& caseId, const quint32& gridIndex)
@ -66,39 +69,18 @@ void getCellCenters(NDArray& cellCenterValues, const QString &hostName, quint16
dv(3) = 3;
cellCenterValues.resize(dv);
while (socket.bytesAvailable() < (qint64)(byteCount))
double* internalMatrixData = cellCenterValues.fortran_vec();
QStringList errorMessages;
if (!RiaSocketDataTransfer::readBlockDataFromSocket(&socket, (char*)(internalMatrixData), byteCount, errorMessages))
{
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
for (int i = 0; i < errorMessages.size(); i++)
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;
error(errorMessages[i].toLatin1().data());
}
OCTAVE_QUIT;
}
//octave_stdout << " riGetCellCenters : I = " << cellCountI <<" J = " << cellCountJ << " K = " << cellCountK << std::endl;
//octave_stdout << " riGetCellCenters : numDoubles = " << valueCount << std::endl;
double* internalMatrixData = cellCenterValues.fortran_vec();
#if 0
octave_idx_type valueCount = cellCenterValues.length();
double val;
for (octave_idx_type i = 0; i < valueCount; i++)
{
socketStream >> internalMatrixData[i];
}
#else
quint64 bytesRead = 0;
bytesRead = socket.read((char*)(internalMatrixData), byteCount);
if (byteCount != bytesRead)
{
error("Could not read binary double data properly from socket");
octave_stdout << "Cell count: " << cellCount << std::endl;
}
#endif
return;
}

View File

@ -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 getCellCorners(NDArray& cellCornerValues, const QString &hostName, quint16 port, const qint32& caseId, const quint32& gridIndex)
@ -67,37 +72,18 @@ void getCellCorners(NDArray& cellCornerValues, const QString &hostName, quint16
dv(4) = 3;
cellCornerValues.resize(dv);
while (socket.bytesAvailable() < (qint64)(byteCount))
double* internalMatrixData = cellCornerValues.fortran_vec();
QStringList errorMessages;
if (!RiaSocketDataTransfer::readBlockDataFromSocket(&socket, (char*)(internalMatrixData), byteCount, errorMessages))
{
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
for (int i = 0; i < errorMessages.size(); i++)
{
error((("Waiting for data: ") + socket.errorString()).toLatin1().data());
return;
error(errorMessages[i].toLatin1().data());
}
OCTAVE_QUIT;
}
double* internalMatrixData = cellCornerValues.fortran_vec();
#if 0
double val;
for (octave_idx_type i = 0; i < valueCount; i++)
{
socketStream >> internalMatrixData[i];
}
#else
quint64 bytesRead = 0;
bytesRead = socket.read((char*)(internalMatrixData), byteCount);
if (byteCount != bytesRead)
{
error("Could not read binary double data properly from socket");
octave_stdout << "Cell count: " << cellCount << std::endl;
}
#endif
return;
}

View File

@ -1,6 +1,11 @@
#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 getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16 serverPort,
const int& caseId, int gridIdx, QString propertyName, const int32NDArray& requestedTimeSteps, QString porosityModel)
@ -22,7 +27,7 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
QString command;
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 += " ";
command += QString::number(static_cast<int>(requestedTimeSteps.elem(i)) - 1); // To make the index 0-based
@ -36,7 +41,7 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
// 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))
{
@ -48,6 +53,7 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
// Read sizes
quint64 totalByteCount;
quint64 cellCountI;
quint64 cellCountJ;
quint64 cellCountK;
@ -59,6 +65,7 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
socketStream >> timestepCount;
totalByteCount = cellCountI*cellCountJ*cellCountK*timestepCount*sizeof(double);
if (!(totalByteCount))
{
error ("Could not find the requested data in ResInsight");
@ -74,28 +81,16 @@ void getGridProperty(NDArray& propertyFrames, const QString &serverName, quint16
propertyFrames.resize(dv);
// Wait for available data
while (socket.bytesAvailable() < (int)totalByteCount)
double* internalMatrixData = propertyFrames.fortran_vec();
QStringList errorMessages;
if (!RiaSocketDataTransfer::readBlockDataFromSocket(&socket, (char*)(internalMatrixData), totalByteCount, errorMessages))
{
if (!socket.waitForReadyRead(riOctavePlugin::longTimeOutMilliSecs))
for (int i = 0; i < errorMessages.size(); i++)
{
error(("Waiting for data : " + socket.errorString()).toLatin1().data());
return ;
error(errorMessages[i].toLatin1().data());
}
OCTAVE_QUIT;
}
qint64 bytesRead = 0;
double * internalMatrixData = propertyFrames.fortran_vec();
// Raw data transfer. Faster.
bytesRead = socket.read((char*)(internalMatrixData ), totalByteCount);
if ((int)totalByteCount != bytesRead)
{
error("Could not read binary double data properly from socket");
return;
}
QString tmp = QString("riGetGridProperty : Read %1").arg(propertyName);

View File

@ -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)
{

View File

@ -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,35 +68,40 @@ void setEclipseProperty(const NDArray& propertyFrames, const QString &hostName,
socketStream << (qint64)singleTimeStepByteCount;
const double* internalData = propertyFrames.fortran_vec();
int dataWritten = socket.write((const char *)internalData, singleTimeStepByteCount*timeStepCount);
if (dataWritten == singleTimeStepByteCount*timeStepCount)
QStringList errorMessages;
if (!RiaSocketDataTransfer::writeBlockDataToSocket(&socket, (const char *)internalData, timeStepCount*singleTimeStepByteCount, errorMessages))
{
QString tmp = QString("riSetGridProperty : Wrote %1").arg(propertyName);
if (caseId == -1)
for (int i = 0; i < errorMessages.size(); i++)
{
tmp += QString(" to current case,");
octave_stdout << errorMessages[i].toStdString();
}
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;
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;
}
QString tmp = QString("riSetGridProperty : Wrote %1").arg(propertyName);
if (caseId == -1)
{
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;
// octave_stdout << "Bytes to write: " << socket.bytesToWrite() << std::endl << std::flush;
socket.waitForBytesWritten(riOctavePlugin::longTimeOutMilliSecs);
OCTAVE_QUIT;
}

View File

@ -24,6 +24,8 @@ namespace riOctavePlugin
const int shortTimeOutMilliSecs = 5000;
const int longTimeOutMilliSecs = 6000000;
const int socketMaxByteCount = 100000;
// Octave data structure : CaseInfo
char caseInfo_CaseId[] = "CaseId";
char caseInfo_CaseName[] = "CaseName";