mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Updated to version 0.8.0
This commit is contained in:
@@ -4,6 +4,7 @@ set(CPP_SOURCES
|
||||
riGetActiveCellProperty.cpp
|
||||
riSetActiveCellProperty.cpp
|
||||
riGetActiveCellInfo.cpp
|
||||
riGetMainGridDimensions.cpp
|
||||
)
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
@@ -48,7 +49,12 @@ else()
|
||||
|
||||
#add_custom_target(oct-files ALL DEPENDS "${OCTAVE_BINARY_OCT_FILES}")
|
||||
|
||||
add_custom_target(octave_plugins ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/riGetActiveCellProperty.oct" "${CMAKE_CURRENT_BINARY_DIR}/riSetActiveCellProperty.oct" "${CMAKE_CURRENT_BINARY_DIR}/riGetActiveCellInfo.oct")
|
||||
add_custom_target(octave_plugins ALL DEPENDS
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/riGetActiveCellProperty.oct"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/riSetActiveCellProperty.oct"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/riGetActiveCellInfo.oct"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/riGetMainGridDimensions.oct"
|
||||
)
|
||||
endif()
|
||||
|
||||
install(FILES ${OCTAVE_BINARY_OCT_FILES} DESTINATION ${RESINSIGHT_FINAL_NAME})
|
||||
|
||||
12
OctavePlugin/OctaveScripts/InputPropTest.m
Normal file
12
OctavePlugin/OctaveScripts/InputPropTest.m
Normal file
@@ -0,0 +1,12 @@
|
||||
addpath("/home/builder/Projects/ResInsightBuildDir/OctavePlugin");
|
||||
PORO = riGetActiveCellProperty("PORO");
|
||||
PERMX = riGetActiveCellProperty("PERMX");
|
||||
IJK = riGetMainGridDimensions();
|
||||
|
||||
GENERATED = PORO .* PERMX;
|
||||
|
||||
GENERATED(10:IJK(1):IJK(1)*IJK(2)*IJK(3)) = 100;
|
||||
GENERATED(10*IJK(1):1:11*IJK(1)) = 100;
|
||||
GENERATED(11*IJK(1):1:12*IJK(1)) = 100;
|
||||
GENERATED(12*IJK(1):1:13*IJK(1)) = 100;
|
||||
riSetActiveCellProperty(GENERATED, "PORO*PERMX");
|
||||
114
OctavePlugin/riGetMainGridDimensions.cpp
Normal file
114
OctavePlugin/riGetMainGridDimensions.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
#include <QtNetwork>
|
||||
#include <octave/oct.h>
|
||||
|
||||
|
||||
void getMainGridDimensions(int32NDArray& gridDimensions, const QString &hostName, quint16 port, QString caseName)
|
||||
{
|
||||
QString serverName = hostName;
|
||||
quint16 serverPort = port;
|
||||
|
||||
const int Timeout = 5 * 1000;
|
||||
|
||||
QTcpSocket socket;
|
||||
socket.connectToHost(serverName, serverPort);
|
||||
|
||||
if (!socket.waitForConnected(Timeout))
|
||||
{
|
||||
error((("Connection: ") + socket.errorString()).toLatin1().data());
|
||||
return;
|
||||
}
|
||||
|
||||
// Create command and send it:
|
||||
|
||||
QString command("GetMainGridDimensions ");
|
||||
command += caseName;
|
||||
QByteArray cmdBytes = command.toLatin1();
|
||||
|
||||
QDataStream socketStream(&socket);
|
||||
socketStream.setVersion(QDataStream::Qt_4_0);
|
||||
|
||||
socketStream << (qint64)(cmdBytes.size());
|
||||
socket.write(cmdBytes);
|
||||
|
||||
// Get response. First wait for the header
|
||||
|
||||
while (socket.bytesAvailable() < (int)(3*sizeof(quint64)))
|
||||
{
|
||||
if (!socket.waitForReadyRead(Timeout))
|
||||
{
|
||||
error((("Wating for header: ") + socket.errorString()).toLatin1().data());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Read timestep count and blocksize
|
||||
|
||||
quint64 iCount;
|
||||
quint64 jCount;
|
||||
quint64 kCount;
|
||||
|
||||
socketStream >> iCount;
|
||||
socketStream >> jCount;
|
||||
socketStream >> kCount;
|
||||
|
||||
dim_vector dv (1);
|
||||
dv(0) = 3;
|
||||
|
||||
gridDimensions.resize(dv);
|
||||
gridDimensions(0) = iCount;
|
||||
gridDimensions(1) = jCount;
|
||||
gridDimensions(2) = kCount;
|
||||
|
||||
|
||||
QString tmp = QString("riGetMainGridDimensions : Read main grid dimensions");
|
||||
if (caseName.isEmpty())
|
||||
{
|
||||
tmp += QString(" from active case.");
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp += QString(" from %1.").arg(caseName);
|
||||
}
|
||||
octave_stdout << tmp.toStdString() << " Dimensions: " << iCount << ", " << jCount << ", " << kCount << std::endl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DEFUN_DLD (riGetMainGridDimensions, args, nargout,
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
" riGetMainGridDimensions( [CaseName/CaseIndex])\n"
|
||||
"\n"
|
||||
"Returns a vector of size 3: [ICount, JCount, KCount] \n"
|
||||
"Containing the dimentions of the main grid in the requested case.\n"
|
||||
"If the Eclipse Case is not defined, the active View in ResInsight is used."
|
||||
)
|
||||
{
|
||||
int nargin = args.length ();
|
||||
if (nargin > 1)
|
||||
{
|
||||
error("riGetActiveCellInfo: Too many arguments. Only the name or index of the case is valid input.\n");
|
||||
print_usage();
|
||||
}
|
||||
else if (nargout < 1)
|
||||
{
|
||||
error("riGetActiveCellInfo: Missing output argument.\n");
|
||||
print_usage();
|
||||
}
|
||||
else
|
||||
{
|
||||
int32NDArray propertyFrames;
|
||||
|
||||
if (nargin > 0)
|
||||
getMainGridDimensions(propertyFrames, "127.0.0.1", 40001, args(0).char_matrix_value().row_as_string(0).c_str());
|
||||
else
|
||||
getMainGridDimensions(propertyFrames, "127.0.0.1", 40001, "");
|
||||
|
||||
return octave_value(propertyFrames);
|
||||
}
|
||||
|
||||
return octave_value_list ();
|
||||
}
|
||||
|
||||
BIN
OctavePlugin/riGetMainGridDimensions.o
Normal file
BIN
OctavePlugin/riGetMainGridDimensions.o
Normal file
Binary file not shown.
Reference in New Issue
Block a user