mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
@@ -3,17 +3,17 @@
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -22,8 +22,8 @@
|
||||
#include "RiaSocketServer.h"
|
||||
#include "RiaSocketTools.h"
|
||||
|
||||
#include "RigGridBase.h"
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigGridBase.h"
|
||||
#include "RigSimWellData.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
@@ -32,22 +32,25 @@
|
||||
|
||||
#include <QTcpSocket>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetWellNames : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetWellNames"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
RimEclipseCase* rimCase = server->findReservoir(caseId);
|
||||
if (!rimCase)
|
||||
return QString( "GetWellNames" );
|
||||
}
|
||||
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
RimEclipseCase* rimCase = server->findReservoir( caseId );
|
||||
if ( !rimCase )
|
||||
{
|
||||
server->showErrorMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID : \"%1\"").arg(caseId));
|
||||
server->showErrorMessage( RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr( "Could not find the case with ID : \"%1\"" ).arg( caseId ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -55,24 +58,24 @@ public:
|
||||
std::vector<QString> wellNames;
|
||||
|
||||
const cvf::Collection<RigSimWellData>& wells = rimCase->eclipseCaseData()->wellResults();
|
||||
|
||||
for (size_t wIdx = 0; wIdx < wells.size(); ++wIdx)
|
||||
|
||||
for ( size_t wIdx = 0; wIdx < wells.size(); ++wIdx )
|
||||
{
|
||||
wellNames.push_back(wells[wIdx]->m_wellName);
|
||||
wellNames.push_back( wells[wIdx]->m_wellName );
|
||||
}
|
||||
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
quint64 byteCount = sizeof( quint64 );
|
||||
quint64 wellCount = wellNames.size();
|
||||
|
||||
for (size_t wIdx = 0; wIdx < wellCount; wIdx++)
|
||||
for ( size_t wIdx = 0; wIdx < wellCount; wIdx++ )
|
||||
{
|
||||
byteCount += wellNames[wIdx].size() * sizeof(QChar);
|
||||
byteCount += wellNames[wIdx].size() * sizeof( QChar );
|
||||
}
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << wellCount;
|
||||
|
||||
for (size_t wIdx = 0; wIdx < wellCount; wIdx++)
|
||||
for ( size_t wIdx = 0; wIdx < wellCount; wIdx++ )
|
||||
{
|
||||
socketStream << wellNames[wIdx];
|
||||
}
|
||||
@@ -81,9 +84,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetWellNames_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetWellNames>(RiaGetWellNames::commandName());
|
||||
|
||||
|
||||
static bool RiaGetWellNames_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetWellNames>(
|
||||
RiaGetWellNames::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -91,17 +93,21 @@ static bool RiaGetWellNames_init = RiaSocketCommandFactory::instance()->register
|
||||
class RiaGetWellStatus : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetWellStatus"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
QString wellName = args[2];
|
||||
return QString( "GetWellStatus" );
|
||||
}
|
||||
|
||||
RimEclipseCase* rimCase = server->findReservoir(caseId);
|
||||
if (!rimCase)
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
QString wellName = args[2];
|
||||
|
||||
RimEclipseCase* rimCase = server->findReservoir( caseId );
|
||||
if ( !rimCase )
|
||||
{
|
||||
server->showErrorMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID : \"%1\"").arg(caseId));
|
||||
server->showErrorMessage( RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr( "Could not find the case with ID : \"%1\"" ).arg( caseId ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -109,48 +115,48 @@ public:
|
||||
// Create a list of all the requested time steps
|
||||
|
||||
std::vector<size_t> requestedTimesteps;
|
||||
//First find the well result for the correct well
|
||||
// First find the well result for the correct well
|
||||
|
||||
const cvf::Collection<RigSimWellData>& allWellRes = rimCase->eclipseCaseData()->wellResults();
|
||||
cvf::ref<RigSimWellData> currentWellResult;
|
||||
for (size_t tsIdx = 0; tsIdx < allWellRes.size(); ++tsIdx)
|
||||
const cvf::Collection<RigSimWellData>& allWellRes = rimCase->eclipseCaseData()->wellResults();
|
||||
cvf::ref<RigSimWellData> currentWellResult;
|
||||
for ( size_t tsIdx = 0; tsIdx < allWellRes.size(); ++tsIdx )
|
||||
{
|
||||
if (allWellRes[tsIdx]->m_wellName == wellName)
|
||||
if ( allWellRes[tsIdx]->m_wellName == wellName )
|
||||
{
|
||||
currentWellResult = allWellRes[tsIdx];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentWellResult.isNull())
|
||||
if ( currentWellResult.isNull() )
|
||||
{
|
||||
server->showErrorMessage(
|
||||
RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the well with name : \"%1\"").arg(wellName));
|
||||
RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr( "Could not find the well with name : \"%1\"" ).arg( wellName ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (args.size() <= 3)
|
||||
if ( args.size() <= 3 )
|
||||
{
|
||||
// Select all timesteps.
|
||||
// Select all timesteps.
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < currentWellResult->m_resultTimeStepIndexToWellTimeStepIndex.size(); ++tsIdx)
|
||||
for ( size_t tsIdx = 0; tsIdx < currentWellResult->m_resultTimeStepIndexToWellTimeStepIndex.size(); ++tsIdx )
|
||||
{
|
||||
requestedTimesteps.push_back(tsIdx);
|
||||
requestedTimesteps.push_back( tsIdx );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool timeStepReadError = false;
|
||||
for (int argIdx = 3; argIdx < args.size(); ++argIdx)
|
||||
for ( int argIdx = 3; argIdx < args.size(); ++argIdx )
|
||||
{
|
||||
bool conversionOk = false;
|
||||
int tsIdx = args[argIdx].toInt(&conversionOk);
|
||||
int tsIdx = args[argIdx].toInt( &conversionOk );
|
||||
|
||||
if (conversionOk)
|
||||
if ( conversionOk )
|
||||
{
|
||||
requestedTimesteps.push_back(tsIdx);
|
||||
requestedTimesteps.push_back( tsIdx );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -158,58 +164,59 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (timeStepReadError)
|
||||
if ( timeStepReadError )
|
||||
{
|
||||
server->showErrorMessage(RiaSocketServer::tr("ResInsight SocketServer: riGetGridProperty : \n")
|
||||
+ RiaSocketServer::tr("An error occured while interpreting the requested timesteps."));
|
||||
server->showErrorMessage(
|
||||
RiaSocketServer::tr( "ResInsight SocketServer: riGetGridProperty : \n" ) +
|
||||
RiaSocketServer::tr( "An error occured while interpreting the requested timesteps." ) );
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<QString> wellTypes;
|
||||
std::vector<qint32> wellStatuses;
|
||||
std::vector<qint32> wellStatuses;
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < requestedTimesteps.size(); ++tsIdx)
|
||||
for ( size_t tsIdx = 0; tsIdx < requestedTimesteps.size(); ++tsIdx )
|
||||
{
|
||||
QString wellType = "NotDefined";
|
||||
qint32 wellStatus = 0;
|
||||
if (currentWellResult->hasWellResult(tsIdx))
|
||||
QString wellType = "NotDefined";
|
||||
qint32 wellStatus = 0;
|
||||
if ( currentWellResult->hasWellResult( tsIdx ) )
|
||||
{
|
||||
switch(currentWellResult->wellResultFrame(tsIdx).m_productionType)
|
||||
switch ( currentWellResult->wellResultFrame( tsIdx ).m_productionType )
|
||||
{
|
||||
case RigWellResultFrame::PRODUCER:
|
||||
wellType = "Producer";
|
||||
break;
|
||||
case RigWellResultFrame::OIL_INJECTOR:
|
||||
wellType = "OilInjector";
|
||||
break;
|
||||
case RigWellResultFrame::WATER_INJECTOR:
|
||||
wellType = "WaterInjector";
|
||||
break;
|
||||
case RigWellResultFrame::GAS_INJECTOR:
|
||||
wellType = "GasInjector";
|
||||
break;
|
||||
case RigWellResultFrame::PRODUCER:
|
||||
wellType = "Producer";
|
||||
break;
|
||||
case RigWellResultFrame::OIL_INJECTOR:
|
||||
wellType = "OilInjector";
|
||||
break;
|
||||
case RigWellResultFrame::WATER_INJECTOR:
|
||||
wellType = "WaterInjector";
|
||||
break;
|
||||
case RigWellResultFrame::GAS_INJECTOR:
|
||||
wellType = "GasInjector";
|
||||
break;
|
||||
}
|
||||
|
||||
wellStatus = currentWellResult->wellResultFrame(tsIdx).m_isOpen ? 1 : 0;
|
||||
wellStatus = currentWellResult->wellResultFrame( tsIdx ).m_isOpen ? 1 : 0;
|
||||
}
|
||||
|
||||
wellTypes.push_back(wellType);
|
||||
wellStatuses.push_back(wellStatus);
|
||||
wellTypes.push_back( wellType );
|
||||
wellStatuses.push_back( wellStatus );
|
||||
}
|
||||
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
quint64 byteCount = sizeof( quint64 );
|
||||
quint64 timeStepCount = wellTypes.size();
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < timeStepCount; tsIdx++)
|
||||
for ( size_t tsIdx = 0; tsIdx < timeStepCount; tsIdx++ )
|
||||
{
|
||||
byteCount += wellTypes[tsIdx].size() * sizeof(QChar);
|
||||
byteCount += sizeof(qint32);
|
||||
byteCount += wellTypes[tsIdx].size() * sizeof( QChar );
|
||||
byteCount += sizeof( qint32 );
|
||||
}
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << timeStepCount;
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < timeStepCount; tsIdx++)
|
||||
for ( size_t tsIdx = 0; tsIdx < timeStepCount; tsIdx++ )
|
||||
{
|
||||
socketStream << wellTypes[tsIdx];
|
||||
socketStream << wellStatuses[tsIdx];
|
||||
@@ -219,9 +226,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetWellStatus_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetWellStatus>(RiaGetWellStatus::commandName());
|
||||
|
||||
|
||||
static bool RiaGetWellStatus_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetWellStatus>(
|
||||
RiaGetWellStatus::commandName() );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -229,51 +235,56 @@ static bool RiaGetWellStatus_init = RiaSocketCommandFactory::instance()->registe
|
||||
class RiaGetWellCells : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetWellCells"); }
|
||||
|
||||
bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) override
|
||||
static QString commandName()
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
QString wellName = args[2];
|
||||
size_t timeStepIdx = args[3].toInt() - 1; // Interpret timeStepIdx from octave as 1-based
|
||||
return QString( "GetWellCells" );
|
||||
}
|
||||
|
||||
RimEclipseCase* rimCase = server->findReservoir(caseId);
|
||||
if (!rimCase)
|
||||
bool interpretCommand( RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream ) override
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
QString wellName = args[2];
|
||||
size_t timeStepIdx = args[3].toInt() - 1; // Interpret timeStepIdx from octave as 1-based
|
||||
|
||||
RimEclipseCase* rimCase = server->findReservoir( caseId );
|
||||
if ( !rimCase )
|
||||
{
|
||||
server->showErrorMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID : \"%1\"").arg(caseId));
|
||||
server->showErrorMessage( RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr( "Could not find the case with ID : \"%1\"" ).arg( caseId ) );
|
||||
|
||||
socketStream << (quint64)0;
|
||||
return true;
|
||||
}
|
||||
|
||||
const cvf::Collection<RigSimWellData>& allWellRes = rimCase->eclipseCaseData()->wellResults();
|
||||
cvf::ref<RigSimWellData> currentWellResult;
|
||||
for (size_t cIdx = 0; cIdx < allWellRes.size(); ++cIdx)
|
||||
|
||||
const cvf::Collection<RigSimWellData>& allWellRes = rimCase->eclipseCaseData()->wellResults();
|
||||
cvf::ref<RigSimWellData> currentWellResult;
|
||||
for ( size_t cIdx = 0; cIdx < allWellRes.size(); ++cIdx )
|
||||
{
|
||||
if (allWellRes[cIdx]->m_wellName == wellName)
|
||||
if ( allWellRes[cIdx]->m_wellName == wellName )
|
||||
{
|
||||
currentWellResult = allWellRes[cIdx];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentWellResult.isNull())
|
||||
if ( currentWellResult.isNull() )
|
||||
{
|
||||
server->showErrorMessage(
|
||||
RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the well with name : \"%1\"").arg(wellName));
|
||||
RiaSocketServer::tr( "ResInsight SocketServer: \n" ) +
|
||||
RiaSocketServer::tr( "Could not find the well with name : \"%1\"" ).arg( wellName ) );
|
||||
|
||||
socketStream << (quint64)0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!currentWellResult->hasWellResult(timeStepIdx))
|
||||
if ( !currentWellResult->hasWellResult( timeStepIdx ) )
|
||||
{
|
||||
socketStream << (quint64)0;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<qint32> cellIs;
|
||||
std::vector<qint32> cellJs;
|
||||
std::vector<qint32> cellIs;
|
||||
std::vector<qint32> cellJs;
|
||||
std::vector<qint32> cellKs;
|
||||
std::vector<qint32> gridIndices;
|
||||
std::vector<qint32> cellStatuses;
|
||||
@@ -281,51 +292,52 @@ public:
|
||||
std::vector<qint32> segmentIds;
|
||||
|
||||
// Fetch results
|
||||
const RigWellResultFrame& wellResFrame = currentWellResult->wellResultFrame(timeStepIdx);
|
||||
const RigWellResultFrame& wellResFrame = currentWellResult->wellResultFrame( timeStepIdx );
|
||||
std::vector<RigGridBase*> grids;
|
||||
rimCase->eclipseCaseData()->allGrids(&grids);
|
||||
rimCase->eclipseCaseData()->allGrids( &grids );
|
||||
|
||||
for (size_t bIdx = 0; bIdx < wellResFrame.m_wellResultBranches.size(); ++bIdx)
|
||||
for ( size_t bIdx = 0; bIdx < wellResFrame.m_wellResultBranches.size(); ++bIdx )
|
||||
{
|
||||
const std::vector<RigWellResultPoint>& branchResPoints = wellResFrame.m_wellResultBranches[bIdx].m_branchResultPoints;
|
||||
for (size_t rpIdx = 0; rpIdx < branchResPoints.size(); ++rpIdx)
|
||||
const std::vector<RigWellResultPoint>& branchResPoints = wellResFrame.m_wellResultBranches[bIdx]
|
||||
.m_branchResultPoints;
|
||||
for ( size_t rpIdx = 0; rpIdx < branchResPoints.size(); ++rpIdx )
|
||||
{
|
||||
const RigWellResultPoint& resPoint = branchResPoints[rpIdx];
|
||||
|
||||
if (resPoint.isCell())
|
||||
if ( resPoint.isCell() )
|
||||
{
|
||||
size_t i;
|
||||
size_t i;
|
||||
size_t j;
|
||||
size_t k;
|
||||
size_t gridIdx = resPoint.m_gridIndex ;
|
||||
grids[gridIdx]->ijkFromCellIndex(resPoint.m_gridCellIndex, &i, &j, &k);
|
||||
size_t gridIdx = resPoint.m_gridIndex;
|
||||
grids[gridIdx]->ijkFromCellIndex( resPoint.m_gridCellIndex, &i, &j, &k );
|
||||
bool isOpen = resPoint.m_isOpen;
|
||||
int branchId = resPoint.m_ertBranchId;
|
||||
int segmentId = resPoint.m_ertSegmentId;
|
||||
int branchId = resPoint.m_ertBranchId;
|
||||
int segmentId = resPoint.m_ertSegmentId;
|
||||
|
||||
cellIs .push_back( static_cast<qint32>(i + 1) ); // NB: 1-based index in Octave
|
||||
cellJs .push_back( static_cast<qint32>(j + 1) ); // NB: 1-based index in Octave
|
||||
cellKs .push_back( static_cast<qint32>(k + 1) ); // NB: 1-based index in Octave
|
||||
gridIndices .push_back( static_cast<qint32>(gridIdx) );
|
||||
cellStatuses.push_back( static_cast<qint32>(isOpen) );
|
||||
branchIds .push_back( branchId );
|
||||
segmentIds .push_back( segmentId);
|
||||
cellIs.push_back( static_cast<qint32>( i + 1 ) ); // NB: 1-based index in Octave
|
||||
cellJs.push_back( static_cast<qint32>( j + 1 ) ); // NB: 1-based index in Octave
|
||||
cellKs.push_back( static_cast<qint32>( k + 1 ) ); // NB: 1-based index in Octave
|
||||
gridIndices.push_back( static_cast<qint32>( gridIdx ) );
|
||||
cellStatuses.push_back( static_cast<qint32>( isOpen ) );
|
||||
branchIds.push_back( branchId );
|
||||
segmentIds.push_back( segmentId );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
quint64 byteCount = sizeof( quint64 );
|
||||
quint64 cellCount = cellIs.size();
|
||||
|
||||
byteCount += cellCount*( 7 * sizeof(qint32));
|
||||
byteCount += cellCount * ( 7 * sizeof( qint32 ) );
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << cellCount;
|
||||
|
||||
for (size_t cIdx = 0; cIdx < cellCount; cIdx++)
|
||||
for ( size_t cIdx = 0; cIdx < cellCount; cIdx++ )
|
||||
{
|
||||
socketStream << cellIs[cIdx];
|
||||
socketStream << cellJs[cIdx];
|
||||
socketStream << cellIs[cIdx];
|
||||
socketStream << cellJs[cIdx];
|
||||
socketStream << cellKs[cIdx];
|
||||
socketStream << gridIndices[cIdx];
|
||||
socketStream << cellStatuses[cIdx];
|
||||
@@ -337,4 +349,5 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetWellCells_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetWellCells>(RiaGetWellCells::commandName());
|
||||
static bool RiaGetWellCells_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetWellCells>(
|
||||
RiaGetWellCells::commandName() );
|
||||
|
||||
Reference in New Issue
Block a user