mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
commit
f2451a2e78
2
.gitignore
vendored
2
.gitignore
vendored
@ -32,4 +32,4 @@ CTest*.cmake
|
||||
|
||||
# Target program
|
||||
/ApplicationCode/ResInsight
|
||||
/.project
|
||||
/.project
|
||||
|
@ -597,13 +597,12 @@ bool RiaApplication::openEclipseCase(const QString& caseName, const QString& cas
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaApplication::openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames)
|
||||
bool RiaApplication::openInputEclipseCaseFromFileNames(const QStringList& fileNames)
|
||||
{
|
||||
RimInputCase* rimInputReservoir = new RimInputCase();
|
||||
m_project->assignCaseIdToCase(rimInputReservoir);
|
||||
|
||||
rimInputReservoir->caseUserDescription = caseName;
|
||||
rimInputReservoir->openDataFileSet(caseFileNames);
|
||||
rimInputReservoir->openDataFileSet(fileNames);
|
||||
|
||||
RimAnalysisModels* analysisModels = m_project->activeOilField() ? m_project->activeOilField()->analysisModels() : NULL;
|
||||
if (analysisModels == NULL) return false;
|
||||
@ -662,7 +661,7 @@ void RiaApplication::createLargeResultsMockModel()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::createInputMockModel()
|
||||
{
|
||||
openInputEclipseCase("Input Mock Debug Model Simple", QStringList("Input Mock Debug Model Simple"));
|
||||
openInputEclipseCaseFromFileNames(QStringList("Input Mock Debug Model Simple"));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1378,7 +1377,11 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
|
||||
imageCompareReporter.addImageDirectoryComparisonSet(testFolderName.toStdString(), reportBaseFolderName.toStdString(), reportGeneratedFolderName.toStdString(), reportDiffFolderName.toStdString());
|
||||
}
|
||||
|
||||
imageCompareReporter.generateHTMLReport(testDir.filePath(RegTestNames::reportFileName).toStdString());
|
||||
QString htmlReportFileName = testDir.filePath(RegTestNames::reportFileName);
|
||||
imageCompareReporter.generateHTMLReport(htmlReportFileName.toStdString());
|
||||
|
||||
// Open HTML report
|
||||
QDesktopServices::openUrl(htmlReportFileName);
|
||||
|
||||
// Generate diff images
|
||||
this->preferences()->resetToDefaults();
|
||||
@ -1397,6 +1400,8 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
|
||||
}
|
||||
m_commandQueueLock.unlock();
|
||||
|
||||
regressionTestSetFixedSizeForAllViews();
|
||||
|
||||
saveSnapshotForAllViews(generatedFolderName);
|
||||
|
||||
QDir baseDir(testCaseFolder.filePath(baseFolderName));
|
||||
@ -1772,7 +1777,8 @@ void RiaApplication::executeRegressionTests(const QString& regressionTestPath)
|
||||
if (mainWnd)
|
||||
{
|
||||
mainWnd->hideAllDockWindows();
|
||||
|
||||
|
||||
mainWnd->setDefaultWindowSize();
|
||||
runRegressionTest(regressionTestPath);
|
||||
|
||||
mainWnd->loadWinGeoAndDockToolBarLayout();
|
||||
@ -1780,3 +1786,34 @@ void RiaApplication::executeRegressionTests(const QString& regressionTestPath)
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::regressionTestSetFixedSizeForAllViews()
|
||||
{
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
if (!mainWnd) return;
|
||||
|
||||
if (m_project.isNull()) return;
|
||||
|
||||
std::vector<RimCase*> projectCases;
|
||||
m_project->allCases(projectCases);
|
||||
|
||||
for (size_t i = 0; i < projectCases.size(); i++)
|
||||
{
|
||||
RimCase* ri = projectCases[i];
|
||||
if (!ri) continue;
|
||||
|
||||
for (size_t j = 0; j < ri->reservoirViews().size(); j++)
|
||||
{
|
||||
RimReservoirView* riv = ri->reservoirViews()[j];
|
||||
|
||||
if (riv && riv->viewer())
|
||||
{
|
||||
// This size is set to match the regression test reference images
|
||||
riv->viewer()->setFixedSize(1000, 745);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
bool openEclipseCaseFromFile(const QString& fileName);
|
||||
bool openEclipseCase(const QString& caseName, const QString& caseFileName);
|
||||
bool addEclipseCases(const QStringList& fileNames);
|
||||
bool openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames);
|
||||
bool openInputEclipseCaseFromFileNames(const QStringList& fileNames);
|
||||
|
||||
bool loadLastUsedProject();
|
||||
QString currentProjectFileName() const;
|
||||
@ -105,6 +105,7 @@ public:
|
||||
void saveSnapshotForAllViews(const QString& snapshotFolderName);
|
||||
void runRegressionTest(const QString& testRootPath);
|
||||
void updateRegressionTest(const QString& testRootPath );
|
||||
void regressionTestSetFixedSizeForAllViews();
|
||||
|
||||
void processNonGuiEvents();
|
||||
|
||||
|
@ -1,150 +1,156 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RiaImageFileCompare.h"
|
||||
#include <QtCore/QProcess>
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaImageFileCompare::RiaImageFileCompare(QString compareExecutable)
|
||||
: m_compareExecutable(compareExecutable)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaImageFileCompare::~RiaImageFileCompare()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaImageFileCompare::reset()
|
||||
{
|
||||
m_imagesEqual = false;
|
||||
m_lastError = IC_NO_ERROR;
|
||||
m_errorMsg = "";
|
||||
m_errorDetails = "";
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaImageFileCompare::runComparison(QString imgFileName, QString refFileName, QString diffFileName)
|
||||
{
|
||||
reset();
|
||||
|
||||
if (m_compareExecutable.isEmpty())
|
||||
{
|
||||
m_lastError = SEVERE_ERROR;
|
||||
m_errorMsg = "Cannot compare images, no compare executable set";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//QString args = QString("-fuzz 2% -lowlight-color white -metric ae \"%1\" \"%2\" \"%3\"").arg(imgFileName).arg(refFileName).arg((diffFileName));
|
||||
QString args = QString("-lowlight-color white -metric ae \"%1\" \"%2\" \"%3\"").arg(imgFileName).arg(refFileName).arg((diffFileName));
|
||||
QString completeCommand = QString("\"%1\" %2").arg(m_compareExecutable).arg(args);
|
||||
|
||||
// Launch process and wait
|
||||
QProcess proc;
|
||||
proc.start(completeCommand);
|
||||
proc.waitForFinished(30000);
|
||||
|
||||
QProcess::ProcessError procError = proc.error();
|
||||
if (procError != QProcess::UnknownError)
|
||||
{
|
||||
m_lastError = SEVERE_ERROR;
|
||||
m_errorMsg = "Error running compare tool process";
|
||||
m_errorDetails = completeCommand;
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray stdErr = proc.readAllStandardError();
|
||||
int procExitCode = proc.exitCode();
|
||||
if (procExitCode == 0)
|
||||
{
|
||||
// Strip out whitespace and look for 0 (as in zero pixel differences)
|
||||
stdErr = stdErr.simplified();
|
||||
if (!stdErr.isEmpty() && stdErr[0] == '0')
|
||||
{
|
||||
m_imagesEqual = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Report non-severe error
|
||||
m_lastError = IC_ERROR;
|
||||
m_errorMsg = "Error running compare tool process";
|
||||
m_errorDetails = stdErr;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaImageFileCompare::imagesEqual() const
|
||||
{
|
||||
return m_imagesEqual;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaImageFileCompare::ErrorType RiaImageFileCompare::error() const
|
||||
{
|
||||
return m_lastError;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaImageFileCompare::errorMessage() const
|
||||
{
|
||||
return m_errorMsg;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaImageFileCompare::errorDetails() const
|
||||
{
|
||||
return m_errorDetails;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RiaImageFileCompare.h"
|
||||
#include <QtCore/QProcess>
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaImageFileCompare::RiaImageFileCompare(QString compareExecutable)
|
||||
: m_compareExecutable(compareExecutable)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaImageFileCompare::~RiaImageFileCompare()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaImageFileCompare::reset()
|
||||
{
|
||||
m_imagesEqual = false;
|
||||
m_lastError = IC_NO_ERROR;
|
||||
m_errorMsg = "";
|
||||
m_errorDetails = "";
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaImageFileCompare::runComparison(QString imgFileName, QString refFileName, QString diffFileName)
|
||||
{
|
||||
reset();
|
||||
|
||||
if (m_compareExecutable.isEmpty())
|
||||
{
|
||||
m_lastError = SEVERE_ERROR;
|
||||
m_errorMsg = "Cannot compare images, no compare executable set";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//QString args = QString("-fuzz 2% -lowlight-color white -metric ae \"%1\" \"%2\" \"%3\"").arg(imgFileName).arg(refFileName).arg((diffFileName));
|
||||
// The ImageMagick compare tool on RedHat 5 does not support the lowlight-color options
|
||||
// Use GCC version as a crude mechanism for disabling use of this option on RedHat5
|
||||
#if (__GNUC__ == 4 && __GNUC_MINOR__ <= 1)
|
||||
QString args = QString("-metric ae \"%1\" \"%2\" \"%3\"").arg(imgFileName).arg(refFileName).arg((diffFileName));
|
||||
#else
|
||||
QString args = QString("-lowlight-color white -metric ae \"%1\" \"%2\" \"%3\"").arg(imgFileName).arg(refFileName).arg((diffFileName));
|
||||
#endif
|
||||
QString completeCommand = QString("\"%1\" %2").arg(m_compareExecutable).arg(args);
|
||||
|
||||
// Launch process and wait
|
||||
QProcess proc;
|
||||
proc.start(completeCommand);
|
||||
proc.waitForFinished(30000);
|
||||
|
||||
QProcess::ProcessError procError = proc.error();
|
||||
if (procError != QProcess::UnknownError)
|
||||
{
|
||||
m_lastError = SEVERE_ERROR;
|
||||
m_errorMsg = "Error running compare tool process";
|
||||
m_errorDetails = completeCommand;
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray stdErr = proc.readAllStandardError();
|
||||
int procExitCode = proc.exitCode();
|
||||
if (procExitCode == 0)
|
||||
{
|
||||
// Strip out whitespace and look for 0 (as in zero pixel differences)
|
||||
stdErr = stdErr.simplified();
|
||||
if (!stdErr.isEmpty() && stdErr[0] == '0')
|
||||
{
|
||||
m_imagesEqual = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Report non-severe error
|
||||
m_lastError = IC_ERROR;
|
||||
m_errorMsg = "Error running compare tool process";
|
||||
m_errorDetails = stdErr;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaImageFileCompare::imagesEqual() const
|
||||
{
|
||||
return m_imagesEqual;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaImageFileCompare::ErrorType RiaImageFileCompare::error() const
|
||||
{
|
||||
return m_lastError;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaImageFileCompare::errorMessage() const
|
||||
{
|
||||
return m_errorMsg;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaImageFileCompare::errorDetails() const
|
||||
{
|
||||
return m_errorDetails;
|
||||
}
|
||||
|
@ -215,6 +215,7 @@ set( EXE_FILES
|
||||
${WIN_RESOURCE}
|
||||
${HEADER_FILES}
|
||||
${REFERENCED_CMAKE_FILES}
|
||||
../ResInsightVersion.cmake
|
||||
)
|
||||
|
||||
add_executable( ResInsight ${EXE_FILES} )
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "ecl_file.h"
|
||||
#include "ecl_kw_magic.h"
|
||||
#include "ecl_grid.h"
|
||||
#include "ecl_rsthead.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
@ -91,25 +92,25 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<Q
|
||||
ecl_kw_type* kwINTEHEAD = ecl_file_iget_named_kw(ecl_file, INTEHEAD_KW, 0);
|
||||
if (kwINTEHEAD)
|
||||
{
|
||||
int day = ecl_kw_iget_int(kwINTEHEAD, INTEHEAD_DAY_INDEX);
|
||||
int month = ecl_kw_iget_int(kwINTEHEAD, INTEHEAD_MONTH_INDEX);
|
||||
int year = ecl_kw_iget_int(kwINTEHEAD, INTEHEAD_YEAR_INDEX);
|
||||
QDate simulationStart(year, month, day);
|
||||
time_t ertTimeStamp = ecl_rsthead_date(kwINTEHEAD);
|
||||
QDateTime simulationStart = QDateTime::fromTime_t(ertTimeStamp);
|
||||
|
||||
for (int i = 0; i < days.size(); i++)
|
||||
{
|
||||
QDateTime reportDateTime(simulationStart);
|
||||
CVF_ASSERT(reportDateTime.isValid());
|
||||
|
||||
double dayValue = days[i];
|
||||
double floorDayValue = cvf::Math::floor(dayValue);
|
||||
double dayFraction = dayValue - floorDayValue;
|
||||
reportDateTime = reportDateTime.addDays(static_cast<int>(floorDayValue));
|
||||
|
||||
double dayFraction = dayValue - floorDayValue;
|
||||
int seconds = static_cast<int>(dayFraction * 24.0 * 60.0 * 60.0);
|
||||
QTime time(0, 0);
|
||||
time = time.addSecs(seconds);
|
||||
|
||||
QDate reportDate = simulationStart;
|
||||
reportDate = reportDate.addDays(static_cast<int>(floorDayValue));
|
||||
reportDateTime.setTime(time);
|
||||
|
||||
QDateTime reportDateTime(reportDate, time);
|
||||
if (std::find(timeStepsFound.begin(), timeStepsFound.end(), reportDateTime) == timeStepsFound.end())
|
||||
{
|
||||
timeStepsFound.push_back(reportDateTime);
|
||||
@ -124,14 +125,10 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<Q
|
||||
ecl_kw_type* kwINTEHEAD = ecl_file_iget_named_kw(ecl_file, INTEHEAD_KW, i);
|
||||
if (kwINTEHEAD)
|
||||
{
|
||||
int day = ecl_kw_iget_int(kwINTEHEAD, INTEHEAD_DAY_INDEX);
|
||||
int month = ecl_kw_iget_int(kwINTEHEAD, INTEHEAD_MONTH_INDEX);
|
||||
int year = ecl_kw_iget_int(kwINTEHEAD, INTEHEAD_YEAR_INDEX);
|
||||
time_t ertTimeStamp = ecl_rsthead_date(kwINTEHEAD);
|
||||
QDateTime reportDateTime = QDateTime::fromTime_t(ertTimeStamp);
|
||||
CVF_ASSERT(reportDateTime.isValid());
|
||||
|
||||
QDate reportDate(year, month, day);
|
||||
CVF_ASSERT(reportDate.isValid());
|
||||
|
||||
QDateTime reportDateTime(reportDate);
|
||||
if (std::find(timeStepsFound.begin(), timeStepsFound.end(), reportDateTime) == timeStepsFound.end())
|
||||
{
|
||||
timeStepsFound.push_back(reportDateTime);
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaVersionInfo.h"
|
||||
|
||||
#include "RigGridManager.h"
|
||||
#include "RigCaseData.h"
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
#include "RifReaderEclipseOutput.h"
|
||||
#include "RifReaderMockModel.h"
|
||||
@ -399,7 +400,7 @@ RimReservoirCellResultsStorage* RimCase::results(RifReaderInterface::PorosityMod
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Relocate the supplied file name, based on the search path as follows:
|
||||
/// fileName, newProjectPath/fileNameWoPath, relocatedPath/fileNameWoPath
|
||||
/// If the file is not found in any of the positions, the fileName is returned unchanged
|
||||
/// If the file is not found in any of the positions, the fileName is returned but converted to Qt Style path separators: "/"
|
||||
///
|
||||
/// The relocatedPath is found in this way:
|
||||
/// use the start of newProjectPath
|
||||
@ -407,11 +408,33 @@ RimReservoirCellResultsStorage* RimCase::results(RifReaderInterface::PorosityMod
|
||||
/// such that the common start of oldProjectPath and m_gridFileName is removed from m_gridFileName
|
||||
/// and replaced with the start of newProjectPath up to where newProjectPath starts to be equal to oldProjectPath
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimCase::relocateFile(const QString& fileName, const QString& newProjectPath, const QString& oldProjectPath,
|
||||
QString RimCase::relocateFile(const QString& orgFileName, const QString& orgNewProjectPath, const QString& orgOldProjectPath,
|
||||
bool* foundFile, std::vector<QString>* searchedPaths)
|
||||
{
|
||||
if (foundFile) *foundFile = true;
|
||||
|
||||
|
||||
// Make sure we have a Qt formatted path ( using "/" not "\")
|
||||
QString fileName = QDir::fromNativeSeparators(orgFileName);
|
||||
QString newProjectPath = QDir::fromNativeSeparators(orgNewProjectPath);
|
||||
QString oldProjectPath = QDir::fromNativeSeparators(orgOldProjectPath);
|
||||
|
||||
// If we from a file or whatever gets a real windows path on linux, we need to manually convert it
|
||||
// because Qt will not. QDir::fromNativeSeparators does nothing on linux.
|
||||
|
||||
bool isWindowsPath = false;
|
||||
if (orgFileName.count("/")) isWindowsPath = false; // "/" are not allowed in a windows path
|
||||
else if (orgFileName.count("\\")
|
||||
&& !QFile::exists(orgFileName)) // To make sure we do not convert single linux files containing "\"
|
||||
{
|
||||
isWindowsPath = true;
|
||||
}
|
||||
|
||||
if (isWindowsPath)
|
||||
{
|
||||
// Windows absolute path detected. transform.
|
||||
fileName.replace(QString("\\"), QString("/"));
|
||||
}
|
||||
|
||||
if (searchedPaths) searchedPaths->push_back(fileName);
|
||||
if (QFile::exists(fileName))
|
||||
{
|
||||
|
@ -75,16 +75,22 @@ RimInputCase::~RimInputCase()
|
||||
/// Open the supplied file set. If no grid data has been read, it will first find the possible
|
||||
/// grid data among the files then read all supported properties from the files matching the grid
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimInputCase::openDataFileSet(const QStringList& filenames)
|
||||
void RimInputCase::openDataFileSet(const QStringList& fileNames)
|
||||
{
|
||||
if (filenames.contains("Input Mock Debug Model"))
|
||||
if (fileNames.contains("Input Mock Debug Model Simple"))
|
||||
{
|
||||
cvf::ref<RifReaderInterface> readerInterface = this->createMockModel(filenames[0]);
|
||||
cvf::ref<RifReaderInterface> readerInterface = this->createMockModel(fileNames[0]);
|
||||
results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
|
||||
results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
|
||||
|
||||
reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->computeDerivedData();
|
||||
reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->computeDerivedData();
|
||||
|
||||
QFileInfo gridFileName(fileNames[0]);
|
||||
QString caseName = gridFileName.completeBaseName();
|
||||
this->caseUserDescription = caseName;
|
||||
|
||||
computeCachedData();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -97,11 +103,16 @@ void RimInputCase::openDataFileSet(const QStringList& filenames)
|
||||
// First find and read the grid data
|
||||
if (this->reservoirData()->mainGrid()->gridPointDimensions() == cvf::Vec3st(0,0,0))
|
||||
{
|
||||
for (int i = 0; i < filenames.size(); i++)
|
||||
for (int i = 0; i < fileNames.size(); i++)
|
||||
{
|
||||
if (RifEclipseInputFileTools::openGridFile(filenames[i], this->reservoirData()))
|
||||
if (RifEclipseInputFileTools::openGridFile(fileNames[i], this->reservoirData()))
|
||||
{
|
||||
m_gridFileName = filenames[i];
|
||||
m_gridFileName = fileNames[i];
|
||||
|
||||
QFileInfo gridFileName(fileNames[i]);
|
||||
QString caseName = gridFileName.completeBaseName();
|
||||
|
||||
this->caseUserDescription = caseName;
|
||||
|
||||
this->reservoirData()->mainGrid()->setFlipAxis(flipXAxis, flipYAxis);
|
||||
|
||||
@ -119,13 +130,13 @@ void RimInputCase::openDataFileSet(const QStringList& filenames)
|
||||
|
||||
// Then read the properties possibly in the grid file
|
||||
QStringList filesToRead;
|
||||
for (int i = 0; i < filenames.size(); i++)
|
||||
for (int i = 0; i < fileNames.size(); i++)
|
||||
{
|
||||
size_t j;
|
||||
bool exist = false;
|
||||
for (j = 0; j < m_additionalFileNames().size(); j++)
|
||||
{
|
||||
if (m_additionalFileNames()[j] == filenames[i])
|
||||
if (m_additionalFileNames()[j] == fileNames[i])
|
||||
{
|
||||
exist = true;
|
||||
}
|
||||
@ -133,7 +144,7 @@ void RimInputCase::openDataFileSet(const QStringList& filenames)
|
||||
|
||||
if (!exist)
|
||||
{
|
||||
filesToRead.push_back(filenames[i]);
|
||||
filesToRead.push_back(fileNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,7 +182,7 @@ bool RimInputCase::openEclipseGridFile()
|
||||
{
|
||||
cvf::ref<RifReaderInterface> readerInterface;
|
||||
|
||||
if (m_gridFileName().contains("Input Mock Debug Model"))
|
||||
if (m_gridFileName().contains("Input Mock Debug Model Simple"))
|
||||
{
|
||||
readerInterface = this->createMockModel(this->m_gridFileName());
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
caf::PdmField<RimInputPropertyCollection*> m_inputPropertyCollection;
|
||||
|
||||
// File open methods
|
||||
void openDataFileSet(const QStringList& filenames);
|
||||
void openDataFileSet(const QStringList& fileNames);
|
||||
void loadAndSyncronizeInputProperties();
|
||||
|
||||
void removeProperty(RimInputProperty* inputProperty);
|
||||
|
@ -107,7 +107,7 @@ RimLegendConfig::RimLegendConfig()
|
||||
{
|
||||
CAF_PDM_InitObject("Legend Definition", ":/Legend.png", "", "");
|
||||
CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of levels", "", "A hint on how many tick marks you whish.","");
|
||||
CAF_PDM_InitField(&m_precision, "Precision", 2, "Significant digits", "", "The number of significant digits displayed in the legend numbers","");
|
||||
CAF_PDM_InitField(&m_precision, "Precision", 4, "Significant digits", "", "The number of significant digits displayed in the legend numbers","");
|
||||
CAF_PDM_InitField(&m_tickNumberFormat, "TickNumberFormat", caf::AppEnum<RimLegendConfig::NumberFormatType>(FIXED), "Number format", "", "","");
|
||||
|
||||
CAF_PDM_InitField(&m_colorRangeMode, "ColorRangeMode", ColorRangeEnum(NORMAL) , "Colors", "", "", "");
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaVersionInfo.h"
|
||||
|
||||
#include "RigGridManager.h"
|
||||
#include "RigCaseData.h"
|
||||
|
@ -1090,7 +1090,7 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex,
|
||||
const RigWellResultPoint* wellResultCell = wellResultFrame.findResultCell(gridIndex, cellIndex);
|
||||
if (wellResultCell)
|
||||
{
|
||||
resultInfoText->append(QString("Well-cell connection info: Well Name: %1 Branch Id: %2 Segment Id: %3\n").arg(singleWellResultData->m_wellName).arg(wellResultCell->m_ertBranchId +1).arg(wellResultCell->m_ertSegmentId+1));
|
||||
resultInfoText->append(QString("Well-cell connection info: Well Name: %1 Branch Id: %2 Segment Id: %3\n").arg(singleWellResultData->m_wellName).arg(wellResultCell->m_ertBranchId).arg(wellResultCell->m_ertSegmentId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +296,12 @@ void RimResultCase::updateFilePathsFromProjectPath(const QString& newProjectPath
|
||||
|
||||
// Update filename and folder paths when opening project from a different file location
|
||||
caseFileName = relocateFile(caseFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths);
|
||||
|
||||
|
||||
#if 0 // Output the search path for debugging
|
||||
for (size_t i = 0; i < searchedPaths.size(); ++i)
|
||||
qDebug() << searchedPaths[i];
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -147,11 +147,13 @@ bool RimUiTreeModelPdm::deletePropertyFilter(const QModelIndex& itemIndex)
|
||||
bool wasSomeFilterActive = propertyFilterCollection->hasActiveFilters();
|
||||
|
||||
// Remove Ui items pointing at the pdm object to delete
|
||||
removeRows_special(itemIndex.row(), 1, itemIndex.parent());
|
||||
removeRows_special(itemIndex.row(), 1, itemIndex.parent()); // To be deleted
|
||||
|
||||
propertyFilterCollection->remove(propertyFilter);
|
||||
delete propertyFilter;
|
||||
|
||||
// updateUiSubTree(propertyFilterCollection); // To be enabled
|
||||
|
||||
if (wasFilterActive)
|
||||
{
|
||||
propertyFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::PROPERTY_FILTERED);
|
||||
@ -187,11 +189,13 @@ bool RimUiTreeModelPdm::deleteRangeFilter(const QModelIndex& itemIndex)
|
||||
bool wasSomeFilterActive = rangeFilterCollection->hasActiveFilters();
|
||||
|
||||
// Remove Ui items pointing at the pdm object to delete
|
||||
removeRows_special(itemIndex.row(), 1, itemIndex.parent());
|
||||
removeRows_special(itemIndex.row(), 1, itemIndex.parent()); // To be deleted
|
||||
|
||||
rangeFilterCollection->remove(rangeFilter);
|
||||
delete rangeFilter;
|
||||
|
||||
// updateUiSubTree(rangeFilterCollection); // To be enabled
|
||||
|
||||
if (wasFilterActive)
|
||||
{
|
||||
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::PROPERTY_FILTERED);
|
||||
@ -221,11 +225,12 @@ bool RimUiTreeModelPdm::deleteReservoirView(const QModelIndex& itemIndex)
|
||||
CVF_ASSERT(reservoirView);
|
||||
|
||||
// Remove Ui items pointing at the pdm object to delete
|
||||
removeRows_special(itemIndex.row(), 1, itemIndex.parent());
|
||||
removeRows_special(itemIndex.row(), 1, itemIndex.parent()); // To be deleted
|
||||
|
||||
reservoirView->eclipseCase()->removeReservoirView(reservoirView);
|
||||
delete reservoirView;
|
||||
|
||||
// updateUiSubTree(reservoirView->eclipseCase()); // To be enabled
|
||||
clearClipboard();
|
||||
|
||||
return true;
|
||||
@ -591,38 +596,28 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(QModelIndex& inserted
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
CVF_ASSERT(proj);
|
||||
|
||||
QModelIndex scriptModelIndex = getModelIndexFromPdmObject(proj->scriptCollection());
|
||||
if (!scriptModelIndex.isValid()) return NULL;
|
||||
|
||||
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(scriptModelIndex);
|
||||
if (!currentItem) return NULL;
|
||||
|
||||
QModelIndex rootIndex = scriptModelIndex.parent();
|
||||
caf::PdmUiTreeItem* rootTreeItem = currentItem->parent();
|
||||
|
||||
// New case group is inserted before the last item, the script item
|
||||
int position = rootTreeItem->childCount() - 1;
|
||||
|
||||
beginInsertRows(rootIndex, position, position);
|
||||
|
||||
RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup;
|
||||
proj->assignIdToCaseGroup(createdObject);
|
||||
|
||||
RimCase* createdReservoir = createdObject->createAndAppendStatisticsCase();
|
||||
proj->assignCaseIdToCase(createdReservoir);
|
||||
createdObject->name = QString("Grid Case Group %1").arg(position + 1);
|
||||
RimAnalysisModels* analysisModels = proj->activeOilField() ? proj->activeOilField()->analysisModels() : NULL;
|
||||
|
||||
if (analysisModels)
|
||||
{
|
||||
RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup;
|
||||
proj->assignIdToCaseGroup(createdObject);
|
||||
|
||||
RimCase* createdReservoir = createdObject->createAndAppendStatisticsCase();
|
||||
proj->assignCaseIdToCase(createdReservoir);
|
||||
createdObject->name = QString("Grid Case Group %1").arg(analysisModels->caseGroups().size() + 1);
|
||||
|
||||
analysisModels->caseGroups().push_back(createdObject);
|
||||
|
||||
this->updateUiSubTree(analysisModels);
|
||||
insertedModelIndex = getModelIndexFromPdmObject(createdObject);
|
||||
|
||||
return createdObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(rootTreeItem, position, createdObject);
|
||||
endInsertRows();
|
||||
|
||||
insertedModelIndex = index(position, 0, rootIndex);
|
||||
|
||||
return createdObject;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -26,15 +26,12 @@ int main(int argc, char *argv[])
|
||||
RiaApplication app(argc, argv);
|
||||
|
||||
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
|
||||
setlocale(LC_NUMERIC,"C");
|
||||
|
||||
RiuMainWindow window;
|
||||
QString platform = cvf::System::is64Bit() ? "(64bit)" : "(32bit)";
|
||||
window.setWindowTitle("ResInsight " + platform);
|
||||
#ifdef CVF_LINUX
|
||||
window.resize(1000, 806);
|
||||
#else
|
||||
window.resize(1000, 800);
|
||||
#endif
|
||||
window.setDefaultWindowSize();
|
||||
window.show();
|
||||
|
||||
if (app.parseArguments())
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "RiaStdInclude.h"
|
||||
#include "RiaSocketCommand.h"
|
||||
#include "RiaSocketServer.h"
|
||||
#include "RiaSocketTools.h"
|
||||
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimResultSlot.h"
|
||||
@ -45,20 +46,9 @@ public:
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
size_t argGridIndex = 0;
|
||||
RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
size_t argGridIndex = args[2].toUInt();
|
||||
|
||||
if (args.size() == 2)
|
||||
{
|
||||
argGridIndex = args[1].toInt();
|
||||
}
|
||||
else if (args.size() == 3)
|
||||
{
|
||||
argCaseGroupId = args[1].toInt();
|
||||
argGridIndex = args[2].toUInt();
|
||||
}
|
||||
|
||||
RimCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
if (!rimCase || !rimCase->reservoirData() || (argGridIndex >= rimCase->reservoirData()->gridCount()) )
|
||||
{
|
||||
// No data available
|
||||
@ -135,37 +125,10 @@ public:
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
QString porosityModelName;
|
||||
RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
|
||||
if (args.size() == 2)
|
||||
{
|
||||
bool numberConversionOk = false;
|
||||
int tmpValue = args[1].toInt(&numberConversionOk);
|
||||
if (numberConversionOk)
|
||||
{
|
||||
argCaseGroupId = tmpValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
porosityModelName = args[1];
|
||||
}
|
||||
}
|
||||
else if (args.size() == 3)
|
||||
{
|
||||
bool numberConversionOk = false;
|
||||
int tmpValue = args[1].toInt(&numberConversionOk);
|
||||
if (numberConversionOk)
|
||||
{
|
||||
argCaseGroupId = args[1].toUInt();
|
||||
porosityModelName = args[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
argCaseGroupId = args[2].toUInt();
|
||||
porosityModelName = args[1];
|
||||
}
|
||||
}
|
||||
QString porosityModelName;
|
||||
porosityModelName = args[2];
|
||||
|
||||
RifReaderInterface::PorosityModelResultType porosityModelEnum = RifReaderInterface::MATRIX_RESULTS;
|
||||
if (porosityModelName.toUpper() == "FRACTURE")
|
||||
@ -173,7 +136,6 @@ public:
|
||||
porosityModelEnum = RifReaderInterface::FRACTURE_RESULTS;
|
||||
}
|
||||
|
||||
RimCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
if (!rimCase || !rimCase->reservoirData())
|
||||
{
|
||||
// No data available
|
||||
@ -240,20 +202,9 @@ public:
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
size_t argGridIndex = 0;
|
||||
RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
size_t argGridIndex = args[2].toUInt();
|
||||
|
||||
if (args.size() == 2)
|
||||
{
|
||||
argGridIndex = args[1].toInt();
|
||||
}
|
||||
else if (args.size() == 3)
|
||||
{
|
||||
argCaseGroupId = args[1].toInt();
|
||||
argGridIndex = args[2].toUInt();
|
||||
}
|
||||
|
||||
RimCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
if (!rimCase || !rimCase->reservoirData() || (argGridIndex >= rimCase->reservoirData()->gridCount()) )
|
||||
{
|
||||
// No data available
|
||||
@ -335,37 +286,10 @@ public:
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
QString porosityModelName;
|
||||
RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
|
||||
if (args.size() == 2)
|
||||
{
|
||||
bool numberConversionOk = false;
|
||||
int tmpValue = args[1].toInt(&numberConversionOk);
|
||||
if (numberConversionOk)
|
||||
{
|
||||
argCaseGroupId = tmpValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
porosityModelName = args[1];
|
||||
}
|
||||
}
|
||||
else if (args.size() == 3)
|
||||
{
|
||||
bool numberConversionOk = false;
|
||||
int tmpValue = args[1].toInt(&numberConversionOk);
|
||||
if (numberConversionOk)
|
||||
{
|
||||
argCaseGroupId = args[1].toUInt();
|
||||
porosityModelName = args[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
argCaseGroupId = args[2].toUInt();
|
||||
porosityModelName = args[1];
|
||||
}
|
||||
}
|
||||
QString porosityModelName;
|
||||
porosityModelName = args[2];
|
||||
|
||||
RifReaderInterface::PorosityModelResultType porosityModelEnum = RifReaderInterface::MATRIX_RESULTS;
|
||||
if (porosityModelName.toUpper() == "FRACTURE")
|
||||
@ -373,7 +297,6 @@ public:
|
||||
porosityModelEnum = RifReaderInterface::FRACTURE_RESULTS;
|
||||
}
|
||||
|
||||
RimCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
if (!rimCase || !rimCase->reservoirData() )
|
||||
{
|
||||
// No data available
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "RiaSocketTools.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuProcessMonitor.h"
|
||||
|
||||
#include "RigCaseData.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
@ -483,20 +484,17 @@ public:
|
||||
|
||||
if (m_invalidActiveCellCountDetected) return true;
|
||||
|
||||
if (!currentClient->bytesAvailable()) return false;
|
||||
// If nothing should be read, or we already have read everything, do nothing
|
||||
|
||||
QDataStream socketStream(currentClient);
|
||||
socketStream.setVersion(riOctavePlugin::qtDataStreamVersion);
|
||||
if ((m_timeStepCountToRead == 0) || (m_currentTimeStepNumberToRead >= m_timeStepCountToRead) ) return true;
|
||||
|
||||
if (!currentClient->bytesAvailable()) return false;
|
||||
|
||||
if (m_timeStepCountToRead != m_requestedTimesteps.size())
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
}
|
||||
|
||||
// If nothing should be read, or we already have read everything, do nothing
|
||||
|
||||
if ((m_timeStepCountToRead == 0) || (m_currentTimeStepNumberToRead >= m_timeStepCountToRead) ) return true;
|
||||
|
||||
// Check if a complete timestep is available, return and whait for readyRead() if not
|
||||
if (currentClient->bytesAvailable() < (int)m_bytesPerTimeStepToRead) return false;
|
||||
|
||||
@ -542,6 +540,9 @@ public:
|
||||
internalMatrixData = readBuffer.data();
|
||||
}
|
||||
|
||||
QDataStream socketStream(currentClient);
|
||||
socketStream.setVersion(riOctavePlugin::qtDataStreamVersion);
|
||||
|
||||
// Read available complete timestepdata
|
||||
|
||||
while ((currentClient->bytesAvailable() >= (int)m_bytesPerTimeStepToRead) && (m_currentTimeStepNumberToRead < m_timeStepCountToRead))
|
||||
@ -656,6 +657,7 @@ private:
|
||||
|
||||
static bool RiaSetActiveCellProperty_init = RiaSocketCommandFactory::instance()->registerCreator<RiaSetActiveCellProperty>(RiaSetActiveCellProperty::commandName());
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -705,7 +707,10 @@ public:
|
||||
|
||||
|
||||
// Read header
|
||||
if (server->currentClient()->bytesAvailable() < (int)sizeof(quint64)*5) return true;
|
||||
if (server->currentClient()->bytesAvailable() < (int)sizeof(quint64)*5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
quint64 cellCountI = 0;
|
||||
quint64 cellCountJ = 0;
|
||||
@ -729,6 +734,8 @@ public:
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") +
|
||||
RiaSocketServer::tr("Zero data to read for ") + ":\"" + m_currentReservoir->caseUserDescription() + "\"\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -791,6 +798,7 @@ public:
|
||||
if (timeStepReadError)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: riGetActiveCellProperty : \n") + RiaSocketServer::tr("An error occured while interpreting the requested timesteps."));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@ -826,13 +834,18 @@ public:
|
||||
|
||||
virtual bool interpretMore(RiaSocketServer* server, QTcpSocket* currentClient)
|
||||
{
|
||||
if (m_invalidDataDetected) return true;
|
||||
|
||||
if (m_invalidDataDetected){
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog("[ResInsight SocketServer] > True \n");
|
||||
return true;
|
||||
}
|
||||
|
||||
// If nothing should be read, or we already have read everything, do nothing
|
||||
|
||||
if ((m_timeStepCountToRead == 0) || (m_currentTimeStepNumberToRead >= m_timeStepCountToRead) ) return true;
|
||||
|
||||
if (!currentClient->bytesAvailable()) return false;
|
||||
|
||||
QDataStream socketStream(currentClient);
|
||||
socketStream.setVersion(riOctavePlugin::qtDataStreamVersion);
|
||||
|
||||
RigGridBase* grid = m_currentReservoir->reservoirData()->grid(m_currentGridIndex);
|
||||
if (!grid)
|
||||
{
|
||||
@ -840,19 +853,7 @@ public:
|
||||
RiaSocketServer::tr("No grid found") + ":\"" + m_currentReservoir->caseUserDescription() + "\"\n");
|
||||
|
||||
m_invalidDataDetected = true;
|
||||
currentClient->abort();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Do nothing if we have not enough data
|
||||
if (m_timeStepCountToRead == 0 || m_bytesPerTimeStepToRead == 0)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") +
|
||||
RiaSocketServer::tr("Zero data to read for ") + ":\"" + m_currentReservoir->caseUserDescription() + "\"\n");
|
||||
|
||||
m_invalidDataDetected = true;
|
||||
currentClient->abort();
|
||||
currentClient->abort(); // Hmmm... should we not let the server handle this ?
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -862,11 +863,7 @@ public:
|
||||
CVF_ASSERT(false);
|
||||
}
|
||||
|
||||
// If nothing should be read, or we already have read everything, do nothing
|
||||
|
||||
if ((m_timeStepCountToRead == 0) || (m_currentTimeStepNumberToRead >= m_timeStepCountToRead) ) return true;
|
||||
|
||||
// Check if a complete timestep is available, return and whait for readyRead() if not
|
||||
// Check if a complete timestep is available, return and wait for readyRead() if not
|
||||
if (currentClient->bytesAvailable() < (int)m_bytesPerTimeStepToRead) return false;
|
||||
|
||||
size_t cellCountFromOctave = m_bytesPerTimeStepToRead / sizeof(double);
|
||||
@ -878,7 +875,6 @@ public:
|
||||
|
||||
m_invalidDataDetected = true;
|
||||
currentClient->abort();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -895,7 +891,7 @@ public:
|
||||
m_scalarResultsToAdd->at(tsId).resize(totalNumberOfCellsIncludingLgrCells, HUGE_VAL);
|
||||
}
|
||||
|
||||
if ((currentClient->bytesAvailable() >= (int)m_bytesPerTimeStepToRead) && (m_currentTimeStepNumberToRead < m_timeStepCountToRead))
|
||||
while ((currentClient->bytesAvailable() >= (int)m_bytesPerTimeStepToRead) && (m_currentTimeStepNumberToRead < m_timeStepCountToRead))
|
||||
{
|
||||
// Read a single time step with data
|
||||
|
||||
@ -904,7 +900,9 @@ public:
|
||||
qint64 bytesRead = currentClient->read((char*)(doubleValues.data()), m_bytesPerTimeStepToRead);
|
||||
size_t doubleValueIndex = 0;
|
||||
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> cellCenterDataAccessObject = m_currentReservoir->reservoirData()->dataAccessObject(grid, m_porosityModelEnum, m_requestedTimesteps[m_currentTimeStepNumberToRead], m_currentScalarIndex);
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> cellCenterDataAccessObject =
|
||||
m_currentReservoir->reservoirData()->dataAccessObject(grid, m_porosityModelEnum, m_requestedTimesteps[m_currentTimeStepNumberToRead], m_currentScalarIndex);
|
||||
|
||||
if (!cellCenterDataAccessObject.isNull())
|
||||
{
|
||||
for (size_t cellIdx = 0; static_cast<size_t>(cellIdx) < cellCountFromOctave; cellIdx++)
|
||||
@ -965,6 +963,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,8 @@
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Socket commands, to be moved into a separate file
|
||||
/// The base class for classes interpreting commands sent via socket.
|
||||
/// Works in close connection with RiaSocketServer
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RiaSocketServer;
|
||||
@ -30,7 +31,18 @@ class RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
virtual ~RiaSocketCommand() {}
|
||||
|
||||
/// This method is supposed to interpret the commands received from the calling socket connection and
|
||||
/// read the data currently available.
|
||||
/// If it read all the data and completed the command, it is supposed to return true. If it did not read all the data,
|
||||
/// it is supposed to return false. The socket server will then assume that the command is not completely interpreted,
|
||||
/// and will continue to call interpretMore() until that method returns true.
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) = 0;
|
||||
|
||||
/// This method is supposed to read whatever more data that is available on the socket connection, and return true if it
|
||||
/// was able to read all the data. If not all the data was available, it must return false, so that the RiaSocketServer
|
||||
/// will call this method again when more data becomes available.
|
||||
virtual bool interpretMore(RiaSocketServer* server, QTcpSocket* currentClient) { return true; }
|
||||
};
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "RiaStdInclude.h"
|
||||
#include "RiaSocketServer.h"
|
||||
#include "RiaSocketCommand.h"
|
||||
#include "RiaSocketTools.h"
|
||||
|
||||
#include <QtGui>
|
||||
#include <QtNetwork>
|
||||
@ -68,6 +69,10 @@ RiaSocketServer::RiaSocketServer(QObject* parent)
|
||||
|
||||
m_tcpServer = new QTcpServer(this);
|
||||
|
||||
m_nextPendingConnectionTimer = new QTimer(this);
|
||||
m_nextPendingConnectionTimer->setInterval(100);
|
||||
m_nextPendingConnectionTimer->setSingleShot(true);
|
||||
|
||||
if (!m_tcpServer->listen(QHostAddress::LocalHost, 40001))
|
||||
{
|
||||
m_errorMessageDialog->showMessage("Octave communication disabled :\n"
|
||||
@ -81,6 +86,7 @@ RiaSocketServer::RiaSocketServer(QObject* parent)
|
||||
return;
|
||||
}
|
||||
|
||||
connect(m_nextPendingConnectionTimer, SIGNAL(timeout()), this, SLOT(handleNextPendingConnection()));
|
||||
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(slotNewClientConnection()));
|
||||
}
|
||||
|
||||
@ -106,54 +112,28 @@ unsigned short RiaSocketServer::serverPort()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::slotNewClientConnection()
|
||||
{
|
||||
// If we are currently handling a connection, just ignore the new one until the queue is empty.
|
||||
// If we are currently handling a connection, just ignore the new one until the current one is disconnected.
|
||||
|
||||
if (m_currentClient != NULL)
|
||||
if (m_currentClient && (m_currentClient->state() == QAbstractSocket::ConnectedState) )
|
||||
{
|
||||
if (m_currentClient->state() == QAbstractSocket::ConnectedState)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_currentCommand)
|
||||
{
|
||||
if (m_currentCommand->interpretMore(this, m_currentClient))
|
||||
{
|
||||
delete m_currentCommand;
|
||||
m_currentCommand = NULL;
|
||||
}
|
||||
//PMonLog("Starting Timer");
|
||||
m_nextPendingConnectionTimer->start(); // Reset and start again
|
||||
return;
|
||||
}
|
||||
|
||||
CVF_ASSERT(m_currentCommand == NULL);
|
||||
}
|
||||
// Read pending data from socket
|
||||
|
||||
terminateCurrentConnection();
|
||||
if (m_currentClient && m_currentCommand)
|
||||
{
|
||||
bool isFinshed = m_currentCommand->interpretMore(this, m_currentClient);
|
||||
|
||||
if (!isFinshed)
|
||||
{
|
||||
m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("Warning : The command did not finish up correctly at the presence of a new one."));
|
||||
}
|
||||
}
|
||||
|
||||
handlePendingIncomingConnectionRequests();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::handleClientConnection(QTcpSocket* clientToHandle)
|
||||
{
|
||||
CVF_ASSERT(clientToHandle != NULL);
|
||||
CVF_ASSERT(m_currentClient == NULL);
|
||||
CVF_ASSERT(m_currentCommand == NULL);
|
||||
|
||||
m_currentClient = clientToHandle;
|
||||
m_currentCommandSize = 0;
|
||||
|
||||
connect(m_currentClient, SIGNAL(disconnected()), this, SLOT(slotCurrentClientDisconnected()));
|
||||
|
||||
if (m_currentClient->bytesAvailable())
|
||||
{
|
||||
this->readCommandFromOctave();
|
||||
}
|
||||
|
||||
connect(m_currentClient, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
|
||||
handleNextPendingConnection();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -195,26 +175,29 @@ RimCase* RiaSocketServer::findReservoir(int caseId)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
/// Reads the command name size, the command string and creates a new command object based on the string read.
|
||||
/// Tries to interpret the command as well.
|
||||
/// Returns whether the command actually was completely finished in one go.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::readCommandFromOctave()
|
||||
bool RiaSocketServer::readCommandFromOctave()
|
||||
{
|
||||
QDataStream socketStream(m_currentClient);
|
||||
socketStream.setVersion(riOctavePlugin::qtDataStreamVersion);
|
||||
|
||||
// If we have not read the currentCommandSize
|
||||
// read the size of the command if all the data is available
|
||||
|
||||
if (m_currentCommandSize == 0)
|
||||
{
|
||||
if (m_currentClient->bytesAvailable() < (int)sizeof(qint64)) return;
|
||||
if (m_currentClient->bytesAvailable() < (int)sizeof(qint64)) return false;
|
||||
|
||||
socketStream >> m_currentCommandSize;
|
||||
}
|
||||
|
||||
// Check if the complete command is available, return and whait for readyRead() if not
|
||||
if (m_currentClient->bytesAvailable() < m_currentCommandSize) return;
|
||||
if (m_currentClient->bytesAvailable() < m_currentCommandSize) return false;
|
||||
|
||||
// Now we can read the command
|
||||
// Now we can read the command name
|
||||
|
||||
QByteArray command = m_currentClient->read( m_currentCommandSize);
|
||||
QTextStream commandStream(command);
|
||||
@ -229,27 +212,19 @@ void RiaSocketServer::readCommandFromOctave()
|
||||
|
||||
CVF_ASSERT(args.size() > 0);
|
||||
|
||||
// Create the actual RiaSocketCommand object that will interpret the socket data
|
||||
|
||||
m_currentCommand = RiaSocketCommandFactory::instance()->create(args[0]);
|
||||
|
||||
if (m_currentCommand)
|
||||
{
|
||||
bool finished = m_currentCommand->interpretCommand(this, args, socketStream);
|
||||
if (finished)
|
||||
{
|
||||
delete m_currentCommand;
|
||||
m_currentCommand = NULL;
|
||||
|
||||
handlePendingIncomingConnectionRequests();
|
||||
return;
|
||||
}
|
||||
return finished;
|
||||
}
|
||||
else
|
||||
{
|
||||
handlePendingIncomingConnectionRequests();
|
||||
|
||||
m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("Unknown command: %1").arg(args[0].data()));
|
||||
terminateCurrentConnection();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,19 +236,56 @@ void RiaSocketServer::slotCurrentClientDisconnected()
|
||||
{
|
||||
if (m_currentCommand)
|
||||
{
|
||||
if (m_currentCommand->interpretMore(this, m_currentClient))
|
||||
{
|
||||
delete m_currentCommand;
|
||||
m_currentCommand = NULL;
|
||||
}
|
||||
// Make sure we read what can be read.
|
||||
bool isFinished = m_currentCommand->interpretMore(this, m_currentClient);
|
||||
|
||||
/// What do we do here ?
|
||||
CVF_ASSERT(m_currentCommand == NULL);
|
||||
if (!isFinished)
|
||||
{
|
||||
m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("Warning : The command was interrupted and did not finish because the connection to octave disconnected."));
|
||||
}
|
||||
}
|
||||
|
||||
terminateCurrentConnection();
|
||||
handleNextPendingConnection();
|
||||
}
|
||||
|
||||
handlePendingIncomingConnectionRequests();
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::slotReadyRead()
|
||||
{
|
||||
if (m_currentCommand)
|
||||
{
|
||||
bool isFinished = m_currentCommand->interpretMore(this, m_currentClient);
|
||||
|
||||
if (isFinished)
|
||||
{
|
||||
handleNextPendingConnection();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isFinished = readCommandFromOctave();
|
||||
if (isFinished)
|
||||
{
|
||||
handleNextPendingConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::setCurrentCaseId(int caseId)
|
||||
{
|
||||
m_currentCaseId = caseId;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiaSocketServer::currentCaseId() const
|
||||
{
|
||||
return m_currentCaseId;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -302,53 +314,47 @@ void RiaSocketServer::terminateCurrentConnection()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::slotReadyRead()
|
||||
void RiaSocketServer::handleNextPendingConnection()
|
||||
{
|
||||
if (m_currentCommand)
|
||||
if (m_currentClient && (m_currentClient->state() == QAbstractSocket::ConnectedState) )
|
||||
{
|
||||
if (m_currentCommand->interpretMore(this, m_currentClient))
|
||||
{
|
||||
delete m_currentCommand;
|
||||
m_currentCommand = NULL;
|
||||
//PMonLog("Starting Timer");
|
||||
m_nextPendingConnectionTimer->start(); // Reset and start again
|
||||
return;
|
||||
}
|
||||
|
||||
handlePendingIncomingConnectionRequests();
|
||||
// Stop timer
|
||||
if (m_nextPendingConnectionTimer->isActive())
|
||||
{
|
||||
//PMonLog("Stopping Timer");
|
||||
m_nextPendingConnectionTimer->stop();
|
||||
}
|
||||
|
||||
terminateCurrentConnection();
|
||||
|
||||
QTcpSocket* clientToHandle = m_tcpServer->nextPendingConnection();
|
||||
if (clientToHandle)
|
||||
{
|
||||
CVF_ASSERT(m_currentClient == NULL);
|
||||
CVF_ASSERT(m_currentCommand == NULL);
|
||||
|
||||
m_currentClient = clientToHandle;
|
||||
m_currentCommandSize = 0;
|
||||
|
||||
connect(m_currentClient, SIGNAL(disconnected()), this, SLOT(slotCurrentClientDisconnected()));
|
||||
connect(m_currentClient, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
|
||||
|
||||
if (m_currentClient->bytesAvailable())
|
||||
{
|
||||
bool isFinished = this->readCommandFromOctave();
|
||||
if (isFinished)
|
||||
{
|
||||
// Call ourselves recursively until there are none left, or until it can not be processed in one go.
|
||||
this->handleNextPendingConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
readCommandFromOctave();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::setCurrentCaseId(int caseId)
|
||||
{
|
||||
m_currentCaseId = caseId;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiaSocketServer::currentCaseId() const
|
||||
{
|
||||
return m_currentCaseId;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketServer::handlePendingIncomingConnectionRequests()
|
||||
{
|
||||
QTcpSocket* newClient = m_tcpServer->nextPendingConnection();
|
||||
if (newClient)
|
||||
{
|
||||
terminateCurrentConnection();
|
||||
|
||||
this->handleClientConnection(newClient);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ class QTcpServer;
|
||||
class QTcpSocket;
|
||||
class QNetworkSession;
|
||||
class QErrorMessage;
|
||||
class QTimer;
|
||||
class RimCase;
|
||||
class RiaSocketCommand;
|
||||
|
||||
@ -59,11 +60,11 @@ private slots:
|
||||
void slotNewClientConnection();
|
||||
void slotCurrentClientDisconnected();
|
||||
void slotReadyRead();
|
||||
void handleNextPendingConnection();
|
||||
|
||||
private:
|
||||
void handleClientConnection( QTcpSocket* clientToHandle);
|
||||
void terminateCurrentConnection();
|
||||
void readCommandFromOctave();
|
||||
void handlePendingIncomingConnectionRequests();
|
||||
bool readCommandFromOctave();
|
||||
|
||||
private:
|
||||
QTcpServer* m_tcpServer;
|
||||
@ -74,5 +75,7 @@ private:
|
||||
|
||||
RiaSocketCommand* m_currentCommand;
|
||||
|
||||
QTimer* m_nextPendingConnectionTimer;
|
||||
|
||||
int m_currentCaseId; // Set to -1 to use default server behavior
|
||||
};
|
||||
|
@ -18,6 +18,7 @@
|
||||
class RimCase;
|
||||
class RiaSocketServer;
|
||||
|
||||
#define PMonLog( MessageString ) RiuMainWindow::instance()->processMonitor()->addStringToLog( MessageString );
|
||||
|
||||
class RiaSocketTools
|
||||
{
|
||||
|
@ -311,9 +311,9 @@ public:
|
||||
int branchId = resPoint.m_ertBranchId;
|
||||
int segmentId = resPoint.m_ertSegmentId;
|
||||
|
||||
cellIs .push_back( static_cast<qint32>(i) );
|
||||
cellJs .push_back( static_cast<qint32>(j) );
|
||||
cellKs .push_back( static_cast<qint32>(k) );
|
||||
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 );
|
||||
|
@ -761,7 +761,7 @@ void RiuMainWindow::slotOpenInputFiles()
|
||||
// Remember the path to next time
|
||||
app->setDefaultFileDialogDirectory("INPUT_FILES", QFileInfo(fileNames.last()).absolutePath());
|
||||
|
||||
app->openInputEclipseCase("Eclipse Input Files", fileNames);
|
||||
app->openInputEclipseCaseFromFileNames(fileNames);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1760,3 +1760,11 @@ void RiuMainWindow::slotExecutePaintEventPerformanceTest()
|
||||
setResultInfo(resultInfo);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindow::setDefaultWindowSize()
|
||||
{
|
||||
resize(1000, 810);
|
||||
}
|
||||
|
@ -93,6 +93,8 @@ public:
|
||||
|
||||
void selectedCases(std::vector<RimCase*>& cases);
|
||||
|
||||
void setDefaultWindowSize();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* event);
|
||||
|
||||
|
@ -52,14 +52,16 @@ RiuProcessMonitor::RiuProcessMonitor(QDockWidget* pParent)
|
||||
m_textEdit->setReadOnly(true);
|
||||
m_textEdit->setLineWrapMode(QPlainTextEdit::NoWrap);
|
||||
|
||||
//QFont font("Courier", 8);
|
||||
QFont font("Terminal", 10);
|
||||
QFont font("Courier", 8);
|
||||
//QFont font("Terminal", 11);
|
||||
m_textEdit->setFont(font);
|
||||
|
||||
QVBoxLayout* pLayout = new QVBoxLayout();
|
||||
pLayout->addLayout(pTopLayout);
|
||||
pLayout->addWidget(m_textEdit);
|
||||
|
||||
pLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
setLayout(pLayout);
|
||||
|
||||
setStatusMsg("N/A", caf::PROCESS_STATE_NORMAL);
|
||||
|
@ -52,12 +52,13 @@ public:
|
||||
void startMonitorWorkProcess(caf::UiProcess* process);
|
||||
void stopMonitorWorkProcess();
|
||||
|
||||
void addStringToLog(const QString& text);
|
||||
|
||||
public slots:
|
||||
void slotClearTextEdit();
|
||||
|
||||
private:
|
||||
void setStatusMsg(const QString& status, int messageType);
|
||||
void addStringToLog(const QString& text);
|
||||
|
||||
private slots:
|
||||
void slotShowProcStatusMsg(const QString& message, int messageType);
|
||||
|
@ -42,6 +42,9 @@ RiuResultInfoPanel::RiuResultInfoPanel(QDockWidget* parent)
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->addWidget(m_textEdit);
|
||||
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,9 @@ set (VIZ_MODULES_FOLDER_NAME Fwk/VizFwk)
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
# Setup the main platform defines
|
||||
#-----------------------------------------------------
|
||||
################################################################################
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
add_definitions(-DCVF_LINUX)
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
@ -16,23 +17,28 @@ else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||
endif()
|
||||
|
||||
option (RESINSIGHT_USE_OPENMP "Enable OpenMP parallellization in the code" ON)
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(CMAKE_CXX_FLAGS "-DCVF_LINUX -pipe -Wextra -Woverloaded-virtual -Wformat")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -g3 -O0 -DDEBUG -D_DEBUG")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNO_DEBUG")
|
||||
endif()
|
||||
|
||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
# Linux specific code
|
||||
set(CMAKE_CXX_FLAGS "-DCVF_LINUX -pipe -Wextra -Woverloaded-virtual -Wformat")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -g3 -O0 -DDEBUG -D_DEBUG")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNO_DEBUG")
|
||||
#set(CMAKE_EXE_LINKER_FLAGS "-Xlinker -rpath .")
|
||||
if(RESINSIGHT_USE_OPENMP)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
|
||||
endif()
|
||||
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g1")
|
||||
ELSE()
|
||||
if(RESINSIGHT_USE_OPENMP)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
|
||||
endif()
|
||||
ENDIF()
|
||||
|
||||
################################################################################
|
||||
# OpenMP
|
||||
################################################################################
|
||||
option (RESINSIGHT_USE_OPENMP "Enable OpenMP parallellization in the code" ON)
|
||||
if (RESINSIGHT_USE_OPENMP)
|
||||
find_package(OpenMP)
|
||||
if(OPENMP_FOUND)
|
||||
message(STATUS "Enabling OpenMP support")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
|
||||
else()
|
||||
message(STATUS "Disabling OpenMP support")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
################################################################################
|
||||
@ -46,8 +52,10 @@ include (ResInsightVersion.cmake)
|
||||
################################################################################
|
||||
|
||||
# Disable install of ERT libs and headers, as Ert code is compiled and linked directly
|
||||
# into ResInsight
|
||||
SET(INSTALL_ERT OFF CACHE BOOL "Build ERT without installing")
|
||||
SET(INSTALL_ERT OFF CACHE BOOL "ERT: Install library")
|
||||
SET(BUILD_SHARED_LIBS OFF CACHE BOOL "ERT: Build shared libraries")
|
||||
SET(ERT_USE_OPENMP ${OPENMP_FOUND} CACHE BOOL "ERT: Compile using OpenMP")
|
||||
|
||||
|
||||
add_subdirectory(ThirdParty/Ert/devel)
|
||||
|
||||
|
@ -1,185 +1,185 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// 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 "cvfBase.h"
|
||||
#include "cvfTextureImage.h"
|
||||
|
||||
#include "cvfqtUtils.h"
|
||||
|
||||
#include <QtCore/QVector>
|
||||
|
||||
namespace cvfqt {
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
/// \class cvfqt::Utils
|
||||
/// \ingroup GuiQt
|
||||
///
|
||||
/// Static helper class for Qt interop
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString Utils::toQString(const cvf::String& ceeString)
|
||||
{
|
||||
if (ceeString.isEmpty())
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
if (sizeof(wchar_t) == 2)
|
||||
{
|
||||
const unsigned short* strPtr = reinterpret_cast<const unsigned short*>(ceeString.c_str());
|
||||
|
||||
return QString::fromUtf16(strPtr);
|
||||
}
|
||||
else if (sizeof(wchar_t) == 4)
|
||||
{
|
||||
const unsigned int* strPtr = reinterpret_cast<const unsigned int*>(ceeString.c_str());
|
||||
|
||||
return QString::fromUcs4(strPtr);
|
||||
}
|
||||
|
||||
CVF_FAIL_MSG("Unexpected sizeof wchar_t");
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::String Utils::fromQString(const QString& qtString)
|
||||
{
|
||||
if (qtString.length() == 0)
|
||||
{
|
||||
return cvf::String();
|
||||
}
|
||||
|
||||
if (sizeof(wchar_t) == 2)
|
||||
{
|
||||
const wchar_t* strPtr = reinterpret_cast<const wchar_t*>(qtString.utf16());
|
||||
|
||||
return cvf::String(strPtr);
|
||||
}
|
||||
else if (sizeof(wchar_t) == 4)
|
||||
{
|
||||
QVector<uint> ucs4Str = qtString.toUcs4();
|
||||
ucs4Str.push_back(0);
|
||||
const wchar_t* strPtr = reinterpret_cast<const wchar_t*>(ucs4Str.data());
|
||||
|
||||
return cvf::String(strPtr);
|
||||
}
|
||||
|
||||
CVF_FAIL_MSG("Unexpected sizeof wchar_t");
|
||||
return cvf::String();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Utils::copyFromQImage(cvf::TextureImage* textureImage, const QImage& qtImage)
|
||||
{
|
||||
CVF_ASSERT(textureImage);
|
||||
|
||||
if (qtImage.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (((int)textureImage->height()) != qtImage.height() || ((int)textureImage->width() != qtImage.width()))
|
||||
{
|
||||
textureImage->allocate(qtImage.width(), qtImage.height());
|
||||
}
|
||||
|
||||
int height = textureImage->height();
|
||||
int width = textureImage->width();
|
||||
|
||||
// Check if QImage has format QImage::Format_ARGB32, and perform a direct memory copy of image data
|
||||
if (qtImage.format() == QImage::Format_ARGB32)
|
||||
{
|
||||
cvf::ubyte* dataPtr = const_cast<cvf::ubyte*>(textureImage->ptr());
|
||||
|
||||
int negy = 0;
|
||||
uint idx = 0;
|
||||
QRgb qtRgbaVal = 0;
|
||||
|
||||
// This loop is a candidate for multi-threading. Testing with OpenMP has so far indicated
|
||||
// quite large variance in performance (Windows Intel i7 with 8 cores).
|
||||
// When this function is called from the paint event,
|
||||
// the user experience is considered better when the paint time is consistent.
|
||||
for (int y = 0 ; y < height; ++y)
|
||||
{
|
||||
negy = height - 1 - y;
|
||||
//##################################################################################################
|
||||
//
|
||||
// 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 "cvfBase.h"
|
||||
#include "cvfTextureImage.h"
|
||||
|
||||
#include "cvfqtUtils.h"
|
||||
|
||||
#include <QtCore/QVector>
|
||||
|
||||
namespace cvfqt {
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
/// \class cvfqt::Utils
|
||||
/// \ingroup GuiQt
|
||||
///
|
||||
/// Static helper class for Qt interop
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString Utils::toQString(const cvf::String& ceeString)
|
||||
{
|
||||
if (ceeString.isEmpty())
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
if (sizeof(wchar_t) == 2)
|
||||
{
|
||||
const unsigned short* strPtr = reinterpret_cast<const unsigned short*>(ceeString.c_str());
|
||||
|
||||
return QString::fromUtf16(strPtr);
|
||||
}
|
||||
else if (sizeof(wchar_t) == 4)
|
||||
{
|
||||
const unsigned int* strPtr = reinterpret_cast<const unsigned int*>(ceeString.c_str());
|
||||
|
||||
return QString::fromUcs4(strPtr);
|
||||
}
|
||||
|
||||
CVF_FAIL_MSG("Unexpected sizeof wchar_t");
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::String Utils::fromQString(const QString& qtString)
|
||||
{
|
||||
if (qtString.length() == 0)
|
||||
{
|
||||
return cvf::String();
|
||||
}
|
||||
|
||||
if (sizeof(wchar_t) == 2)
|
||||
{
|
||||
const wchar_t* strPtr = reinterpret_cast<const wchar_t*>(qtString.utf16());
|
||||
|
||||
return cvf::String(strPtr);
|
||||
}
|
||||
else if (sizeof(wchar_t) == 4)
|
||||
{
|
||||
QVector<uint> ucs4Str = qtString.toUcs4();
|
||||
ucs4Str.push_back(0);
|
||||
const wchar_t* strPtr = reinterpret_cast<const wchar_t*>(ucs4Str.data());
|
||||
|
||||
return cvf::String(strPtr);
|
||||
}
|
||||
|
||||
CVF_FAIL_MSG("Unexpected sizeof wchar_t");
|
||||
return cvf::String();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Utils::copyFromQImage(cvf::TextureImage* textureImage, const QImage& qtImage)
|
||||
{
|
||||
CVF_ASSERT(textureImage);
|
||||
|
||||
if (qtImage.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (((int)textureImage->height()) != qtImage.height() || ((int)textureImage->width() != qtImage.width()))
|
||||
{
|
||||
textureImage->allocate(qtImage.width(), qtImage.height());
|
||||
}
|
||||
|
||||
int height = textureImage->height();
|
||||
int width = textureImage->width();
|
||||
|
||||
// Check if QImage has format QImage::Format_ARGB32, and perform a direct memory copy of image data
|
||||
if (qtImage.format() == QImage::Format_ARGB32)
|
||||
{
|
||||
cvf::ubyte* dataPtr = const_cast<cvf::ubyte*>(textureImage->ptr());
|
||||
|
||||
int negy = 0;
|
||||
uint idx = 0;
|
||||
QRgb qtRgbaVal = 0;
|
||||
|
||||
// This loop is a candidate for multi-threading. Testing with OpenMP has so far indicated
|
||||
// quite large variance in performance (Windows Intel i7 with 8 cores).
|
||||
// When this function is called from the paint event,
|
||||
// the user experience is considered better when the paint time is consistent.
|
||||
for (int y = 0 ; y < height; ++y)
|
||||
{
|
||||
negy = height - 1 - y;
|
||||
const uchar* s = qtImage.scanLine(negy);
|
||||
|
||||
for (int x = 0 ; x < width; ++x)
|
||||
{
|
||||
qtRgbaVal = ((QRgb*)s)[x]; // Taken from QImage::pixel(int x, int y)
|
||||
|
||||
idx = 4*(y*width + x);
|
||||
dataPtr[idx] = qRed(qtRgbaVal);
|
||||
dataPtr[idx + 1] = qGreen(qtRgbaVal);
|
||||
dataPtr[idx + 2] = qBlue(qtRgbaVal);
|
||||
dataPtr[idx + 3] = qAlpha(qtRgbaVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int y = 0 ; y < height; ++y)
|
||||
{
|
||||
int negy = height - 1 - y;
|
||||
QRgb qtRgbaVal;
|
||||
cvf::Color4ub cvfRgbVal;
|
||||
for (int x = 0 ; x < width; ++x)
|
||||
{
|
||||
qtRgbaVal = qtImage.pixel(x, negy);
|
||||
cvfRgbVal.set(qRed(qtRgbaVal), qGreen(qtRgbaVal), qBlue(qtRgbaVal), qAlpha(qtRgbaVal));
|
||||
textureImage->setPixel(x, y, cvfRgbVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace cvfqt
|
||||
|
||||
|
||||
|
||||
for (int x = 0 ; x < width; ++x)
|
||||
{
|
||||
qtRgbaVal = ((QRgb*)s)[x]; // Taken from QImage::pixel(int x, int y)
|
||||
|
||||
idx = 4*(y*width + x);
|
||||
dataPtr[idx] = qRed(qtRgbaVal);
|
||||
dataPtr[idx + 1] = qGreen(qtRgbaVal);
|
||||
dataPtr[idx + 2] = qBlue(qtRgbaVal);
|
||||
dataPtr[idx + 3] = qAlpha(qtRgbaVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int y = 0 ; y < height; ++y)
|
||||
{
|
||||
int negy = height - 1 - y;
|
||||
QRgb qtRgbaVal;
|
||||
cvf::Color4ub cvfRgbVal;
|
||||
for (int x = 0 ; x < width; ++x)
|
||||
{
|
||||
qtRgbaVal = qtImage.pixel(x, negy);
|
||||
cvfRgbVal.set(qRed(qtRgbaVal), qGreen(qtRgbaVal), qBlue(qtRgbaVal), qAlpha(qtRgbaVal));
|
||||
textureImage->setPixel(x, y, cvfRgbVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace cvfqt
|
||||
|
||||
|
||||
|
@ -347,11 +347,10 @@ void Glyph::setupAndBindTexture(OpenGLContext* oglContext, bool software)
|
||||
texture->setWrapMode(Texture2D_FF::CLAMP);
|
||||
texture->setMinFilter(Texture2D_FF::NEAREST);
|
||||
texture->setMagFilter(Texture2D_FF::NEAREST);
|
||||
texture->setupTexture(oglContext);
|
||||
texture->setupTextureParams(oglContext);
|
||||
|
||||
ref<RenderStateTextureMapping_FF> textureMapping = new RenderStateTextureMapping_FF(texture.p());
|
||||
textureMapping->setTextureFunction(RenderStateTextureMapping_FF::MODULATE);
|
||||
textureMapping->setupTexture(oglContext);
|
||||
|
||||
m_textureBindings = textureMapping;
|
||||
#endif
|
||||
@ -364,7 +363,6 @@ void Glyph::setupAndBindTexture(OpenGLContext* oglContext, bool software)
|
||||
sampler->setMagFilter(Sampler::NEAREST);
|
||||
|
||||
ref<Texture> texture = new Texture(m_textureImage.p());
|
||||
texture->setupTexture(oglContext);
|
||||
|
||||
RenderStateTextureBindings* textureBindings = new RenderStateTextureBindings(texture.p(), sampler.p(), "dummy");
|
||||
textureBindings->setupTextures(oglContext);
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "cvfRenderStateDepth.h"
|
||||
#include "cvfRenderStateBlending.h"
|
||||
#include "cvfRenderStatePolygonOffset.h"
|
||||
#include "cvfOpenGLCapabilities.h"
|
||||
|
||||
#ifndef CVF_OPENGL_ES
|
||||
#include "cvfRenderState_FF.h"
|
||||
@ -349,8 +350,20 @@ void TextDrawer::doRender2d(OpenGLContext* oglContext, const MatrixState& matrix
|
||||
|
||||
RenderStateLighting_FF light(false);
|
||||
light.applyOpenGL(oglContext);
|
||||
#endif
|
||||
|
||||
// The active texture may be set to something different than unit 0 if we end up using
|
||||
// software rendering here, BUT the context actually has higher capabilities
|
||||
// Must be set before any texture related OpenGL calls
|
||||
if (oglContext->capabilities()->supportsOpenGL2())
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
|
||||
// Will get turned on during rendering of text, but must be off for background and border
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
projCam.applyOpenGL();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -417,7 +430,7 @@ void TextDrawer::doRender2d(OpenGLContext* oglContext, const MatrixState& matrix
|
||||
#ifndef CVF_OPENGL_ES
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4fv(m_backgroundColor.ptr());
|
||||
glColor3fv(m_backgroundColor.ptr());
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glVertex3fv(v1);
|
||||
glVertex3fv(v2);
|
||||
|
@ -140,18 +140,26 @@ else()
|
||||
|
||||
# Copy Octave generated *.oct files to application folder, will make it possible to use Octave functions
|
||||
# directly from the location of the ResInsight binaries
|
||||
if (MSVC)
|
||||
if (true)
|
||||
foreach (oct_bin ${OCTAVE_BINARY_OCT_FILES})
|
||||
|
||||
get_filename_component(Filename "${oct_bin}" NAME)
|
||||
|
||||
add_custom_command(TARGET octave_plugins POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${oct_bin}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/../ApplicationCode/$<CONFIGURATION>/${Filename}"
|
||||
)
|
||||
if(MSVC)
|
||||
add_custom_command(TARGET octave_plugins POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${oct_bin}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/../ApplicationCode/$<CONFIGURATION>/${Filename}"
|
||||
)
|
||||
else()
|
||||
add_custom_command(TARGET octave_plugins POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${oct_bin}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/../ApplicationCode/${Filename}"
|
||||
)
|
||||
endif()
|
||||
endforeach( oct_bin )
|
||||
endif(MSVC)
|
||||
endif()
|
||||
|
||||
# Make ResInsight dependant on Octave, makes it easiser to debug Octave functionality by compiling ResInsight
|
||||
add_dependencies(ResInsight octave_plugins)
|
||||
|
328
OctavePlugin/OctaveScripts/OctaveInterfaceTest.m
Normal file
328
OctavePlugin/OctaveScripts/OctaveInterfaceTest.m
Normal file
@ -0,0 +1,328 @@
|
||||
### The case with caseid 1 has to be selected/active in ResInsight when running this test-script
|
||||
### Coarsening and Dual porosity is not exercised by this tes yet. We need models
|
||||
|
||||
### CaseInfo riGetCurrentCase()
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetCurrentCase\n");
|
||||
%! caseInfo = riGetCurrentCase();
|
||||
%! assert ( caseInfo.CaseId == 1 );
|
||||
%! assert ( caseInfo.CaseName == "BRUGGE_0000" );
|
||||
%! assert ( caseInfo.CaseType == "SourceCase" );
|
||||
%! assert ( caseInfo.CaseGroupId == 0 );
|
||||
|
||||
### Vector[CaseInfo] riGetSelectedCases()
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetSelectedCases\n");
|
||||
%! caseInfoVector1 = riGetSelectedCases();
|
||||
%! assert ( caseInfoVector1.CaseId == 1 );
|
||||
%! assert ( caseInfoVector1.CaseName == "BRUGGE_0000" );
|
||||
%! assert ( caseInfoVector1.CaseType == "SourceCase" );
|
||||
%! assert ( caseInfoVector1.CaseGroupId == 0 );
|
||||
|
||||
|
||||
### Vector[CaseGroupInfo] riGetCaseGroups()
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetCaseGroups\n");
|
||||
%! caseGroupInfoVector = riGetCaseGroups();
|
||||
%! assert (rows(caseGroupInfoVector) == 2);
|
||||
%! assert (caseGroupInfoVector(2).CaseGroupId == 1);
|
||||
%! assert (caseGroupInfoVector(2).CaseGroupName == "Grid Case Group 2");
|
||||
|
||||
### Vector[CaseInfo] riGetCases([CaseGroupId])
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetCases\n");
|
||||
%! caseInfoVector3 = riGetCases();
|
||||
%! assert(rows(caseInfoVector3) == 10);
|
||||
%! assert(caseInfoVector3(2).CaseName == "BRUGGE_0040");
|
||||
%! assert(caseInfoVector3(2).CaseType == "ResultCase");
|
||||
%! assert(caseInfoVector3(3).CaseType == "StatisticsCase");
|
||||
%! assert(caseInfoVector3(4).CaseType == "SourceCase");
|
||||
%! caseinfoVector3 = riGetCases(1);
|
||||
%! assert(rows(caseinfoVector3) == 3);
|
||||
|
||||
|
||||
### Matrix[numActiveCells][9] riGetActiveCellInfo([CaseId], [PorosityModel = "Matrix"|"Fracture"] )
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetActiveCellInfo\n");
|
||||
%! ACInfo1 = riGetActiveCellInfo();
|
||||
%! assert(rows(ACInfo1) == 43374);
|
||||
%! assert(columns(ACInfo1) == 9);
|
||||
%! ACInfo2 = riGetActiveCellInfo("Matrix");
|
||||
%! assert(ACInfo1 == ACInfo2);
|
||||
%! ACInfo3 = riGetActiveCellInfo(1, "Matrix");
|
||||
%! assert(ACInfo1 == ACInfo3);
|
||||
%! ACInfo4 = riGetActiveCellInfo(1);
|
||||
%! assert(ACInfo1 == ACInfo4);
|
||||
|
||||
### Matrix[numCoarseGroups][6] riGetCoarseningInfo([CaseId])
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetCoarseningInfo\n");
|
||||
%! CoarseInfo1 = riGetCoarseningInfo();
|
||||
%! assert(rows(CoarseInfo1) == 0);
|
||||
%! assert(columns(CoarseInfo1) == 6);
|
||||
%! CoarseInfo2 = riGetCoarseningInfo(1);
|
||||
%! assert(CoarseInfo1 == CoarseInfo2);
|
||||
|
||||
### Matrix[numGrids][3] riGetGridDimensions([CaseId])
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetGridDimensions\n");
|
||||
%! GridDims1 = riGetGridDimensions();
|
||||
%! assert(rows(GridDims1) == 1);
|
||||
%! assert(columns(GridDims1) == 3);
|
||||
|
||||
%! GridDims2 = riGetGridDimensions(0);
|
||||
%! assert(rows(GridDims2) == 2);
|
||||
%! assert(columns(GridDims2) == 3);
|
||||
%! assert( GridDims2(2,1) == 12);
|
||||
%! assert( GridDims2(2,3) == 36);
|
||||
|
||||
### Vector[TimeStepDate] riGetTimestepDates([CaseId])
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetTimestepDates\n");
|
||||
%! TimeStepDates1 = riGetTimeStepDates();
|
||||
%! assert(rows(TimeStepDates1) == 11);
|
||||
%! assert(TimeStepDates1(2).Year == 1997);
|
||||
%! assert(TimeStepDates1(2).Month == 01);
|
||||
%! assert(TimeStepDates1(2).Day == 31);
|
||||
%! assert(TimeStepDates1(2).Hour == 0);
|
||||
%! assert(TimeStepDates1(2).Minute == 0);
|
||||
%! assert(TimeStepDates1(2).Second == 0);
|
||||
%! TimeStepDates2 = riGetTimeStepDates(1);
|
||||
%! assert(TimeStepDates2(7).Year == 1997);
|
||||
%! assert(TimeStepDates2(7).Month == 06);
|
||||
%! assert(TimeStepDates2(7).Day == 30);
|
||||
%! assert(TimeStepDates2(7).Hour == 0);
|
||||
%! assert(TimeStepDates2(7).Minute == 0);
|
||||
%! assert(TimeStepDates2(7).Second == 0);
|
||||
|
||||
### Vector[DecimalDay] riGetTimestepDays([CaseId])
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetTimestepDays\n");
|
||||
%! TimeStepDays1 = riGetTimeStepDays();
|
||||
%! assert(TimeStepDays1(1) == 0);
|
||||
%! assert(TimeStepDays1(2) == 30);
|
||||
%! assert(rows(TimeStepDays1) == 11);
|
||||
%! TimeStepDays2 = riGetTimeStepDays(1);
|
||||
%! assert(rows(TimeStepDays2) == 11);
|
||||
|
||||
|
||||
### Vector[PropertyInfo] riGetPropertyNames([CaseId] ], [PorosityModel = "Matrix"|"Fracture"])
|
||||
%!xtest
|
||||
%! printf ("===== Testing ====> riGetPropertyNames\n");
|
||||
%! PropertyInfos1 = riGetPropertyNames();
|
||||
%! PropertyInfos2 = riGetPropertyNames(1);
|
||||
%! PropertyInfos3 = riGetPropertyNames("Matrix");
|
||||
%! PropertyInfos4 = riGetPropertyNames(1, "Matrix");
|
||||
%! assert(rows(PropertyInfos1) == 26)
|
||||
%! assert(PropertyInfos1(1).PropName == "PRESSURE");
|
||||
%! assert(PropertyInfos1(1).PropType == "DynamicNative");
|
||||
%! assert(PropertyInfos1(26).PropType == "StaticNative");
|
||||
|
||||
### Matrix[numActiveCells][numTimestepsRequested] riGetActiveCellProperty([CaseId], PropertyName, [RequestedTimeSteps], [PorosityModel = "Matrix"|"Fracture"])
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetActiveCellProperty\n");
|
||||
%! ActivePropData1 = riGetActiveCellProperty("SOIL");
|
||||
%! assert (rows(ActivePropData1) == rows(riGetActiveCellInfo()));
|
||||
%! assert (columns(ActivePropData1) == rows(riGetTimeStepDays()));
|
||||
%! ActivePropData2 = riGetActiveCellProperty("SOIL", "Matrix");
|
||||
%! assert (ActivePropData2 == ActivePropData1);
|
||||
%! ActivePropData3 = riGetActiveCellProperty("SOIL", [1,3]);
|
||||
%! assert (columns(ActivePropData3) == 2);
|
||||
%! assert (ActivePropData3(:,2) == ActivePropData1(:,3));
|
||||
%! ActivePropData4 = riGetActiveCellProperty("SOIL", [1,3], "Matrix");
|
||||
%! assert (ActivePropData3 == ActivePropData4);
|
||||
%! ActivePropData5 = riGetActiveCellProperty(1, "SOIL");
|
||||
%! assert (ActivePropData5 == ActivePropData1);
|
||||
%! ActivePropData6 = riGetActiveCellProperty(1, "SOIL", [1,3]);
|
||||
%! assert (ActivePropData6 == ActivePropData3);
|
||||
%! ActivePropData7 = riGetActiveCellProperty(1, "SOIL", [1,3], "Matrix");
|
||||
%! assert (ActivePropData7 == ActivePropData3);
|
||||
%! ActivePropData8 = riGetActiveCellProperty(1, "SOIL", "Matrix");
|
||||
%! assert (ActivePropData8 == ActivePropData1);
|
||||
|
||||
### Matrix[numI][numJ][numK][numTimestepsRequested] riGetGridProperty([CaseId], GridIndex , PropertyName, [RequestedTimeSteps], [PorosityModel = "Matrix"|"Fracture"])
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetGridProperty\n");
|
||||
%! GridProps1 = riGetGridProperty( 0 , "SOIL" );
|
||||
%! assert( ndims (GridProps1) == 4);
|
||||
%! [ni, nj, nk, nts ] = size(GridProps1);
|
||||
%! disp(nts);
|
||||
%! assert(nts == 11);
|
||||
%! assert(ni == 139);
|
||||
%! assert(nj == 48);
|
||||
%! assert(nk == 9);
|
||||
%! assert(GridProps1(62,30,1,3), 0.59058, 0.00001);
|
||||
|
||||
%! GridProps2 = riGetGridProperty( 0 , "SOIL", [1,3]);
|
||||
%! assert( ndims (GridProps2) == 4);
|
||||
%! [ni, nj, nk, nts ] = size(GridProps2);
|
||||
%! assert(nts == 2);
|
||||
%! assert(ni == 139);
|
||||
%! assert(nj == 48);
|
||||
%! assert(nk == 9);
|
||||
%! assert(GridProps2(62,30,1,2), 0.59058, 0.00001);
|
||||
|
||||
%! GridProps3 = riGetGridProperty( 0 , "SOIL", [1,3], "Matrix");
|
||||
%! GridProps4 = riGetGridProperty( 0 , "SOIL", "Matrix");
|
||||
%! GridProps5 = riGetGridProperty(1, 0 , "SOIL" );
|
||||
%! GridProps6 = riGetGridProperty(1, 0 , "SOIL", [1,3]);
|
||||
%! GridProps7 = riGetGridProperty(1, 0 , "SOIL", [1,3], "Matrix");
|
||||
%! GridProps8 = riGetGridProperty(1, 0 , "SOIL", "Matrix");
|
||||
|
||||
%! assert(GridProps3 == GridProps2);
|
||||
%! assert(GridProps4 == GridProps1);
|
||||
%! assert(GridProps5 == GridProps1);
|
||||
%! assert(GridProps6 == GridProps2);
|
||||
%! assert(GridProps7 == GridProps2);
|
||||
%! assert(GridProps8 == GridProps1);
|
||||
|
||||
|
||||
### riSetActiveCellProperty( Matrix[numActiveCells][numTimeSteps], [CaseId], PropertyName, [TimeStepIndices], [PorosityModel = "Matrix"|"Fracture"])
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riSetActiveCellProperty\n");
|
||||
%! ActivePropData1 = riGetActiveCellProperty("SOIL");
|
||||
%! ActivePropData3 = riGetActiveCellProperty("SOIL", [1,3]);
|
||||
|
||||
%! riSetActiveCellProperty( ActivePropData1, "PropertyName1" );
|
||||
%! riSetActiveCellProperty( ActivePropData3, "PropertyName2", [1,3]);
|
||||
%! riSetActiveCellProperty( ActivePropData3, "PropertyName3", [1,3], "Matrix");
|
||||
%! riSetActiveCellProperty( ActivePropData1, "PropertyName4", "Matrix");
|
||||
%! riSetActiveCellProperty( ActivePropData1, 1, "PropertyName5" );
|
||||
%! riSetActiveCellProperty( ActivePropData3, 1, "PropertyName6", [1,3]);
|
||||
%! riSetActiveCellProperty( ActivePropData3, 1, "PropertyName7", [1,3], "Matrix");
|
||||
%! riSetActiveCellProperty( ActivePropData1, 1, "PropertyName8", "Matrix");
|
||||
|
||||
%! assert(ActivePropData1 == riGetActiveCellProperty("PropertyName1"));
|
||||
%! assert(ActivePropData3 == riGetActiveCellProperty("PropertyName2", [1,3]));
|
||||
%! assert(ActivePropData3 == riGetActiveCellProperty("PropertyName3", [1,3]));
|
||||
%! assert(ActivePropData1 == riGetActiveCellProperty("PropertyName4", "Matrix"));
|
||||
%! assert(ActivePropData1 == riGetActiveCellProperty("PropertyName5"));
|
||||
%! assert(ActivePropData3 == riGetActiveCellProperty( 1, "PropertyName6", [1,3]));
|
||||
%! assert(ActivePropData3 == riGetActiveCellProperty( 1, "PropertyName7", [1,3], "Matrix"));
|
||||
%! assert(ActivePropData1 == riGetActiveCellProperty( 1, "PropertyName8", "Matrix"));
|
||||
|
||||
### riSetGridProperty( Matrix[numI][numJ][numK][numTimeSteps], [CaseId], GridIndex, PropertyName, [TimeStepIndices], [PorosityModel = "Matrix"|"Fracture"])
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riSetGridProperty\n");
|
||||
%! GridProps1 = riGetGridProperty( 0 , "SOIL" );
|
||||
%! GridProps2 = riGetGridProperty( 0 , "SOIL", [1,3]);
|
||||
|
||||
%! riSetGridProperty( GridProps1, 0, "PropertyName11" );
|
||||
%! riSetGridProperty( GridProps2, 0, "PropertyName12", [1,3]);
|
||||
%! riSetGridProperty( GridProps2, 0, "PropertyName13", [1,3], "Matrix");
|
||||
%! riSetGridProperty( GridProps1, 0, "PropertyName14", "Matrix");
|
||||
%! riSetGridProperty( GridProps1, 1, 0, "PropertyName15" );
|
||||
%! riSetGridProperty( GridProps2, 1, 0, "PropertyName16", [1,3]);
|
||||
%! riSetGridProperty( GridProps2, 1, 0, "PropertyName17", [1,3], "Matrix");
|
||||
%! riSetGridProperty( GridProps1, 1, 0, "PropertyName18", "Matrix");
|
||||
|
||||
%! assert(GridProps1 == riGetGridProperty( 0, "PropertyName11"));
|
||||
%! assert(GridProps2 == riGetGridProperty( 0, "PropertyName12", [1,3]));
|
||||
%! assert(GridProps2 == riGetGridProperty( 0, "PropertyName13", [1,3], "Matrix"));
|
||||
%! assert(GridProps1 == riGetGridProperty( 0, "PropertyName14", "Matrix"));
|
||||
%! assert(GridProps1 == riGetGridProperty( 1, 0, "PropertyName15"));
|
||||
%! assert(GridProps2 == riGetGridProperty( 1, 0, "PropertyName16", [1,3]));
|
||||
%! assert(GridProps2 == riGetGridProperty( 1, 0, "PropertyName17", [1,3], "Matrix"));
|
||||
%! assert(GridProps1 == riGetGridProperty( 1, 0, "PropertyName18", "Matrix"));
|
||||
|
||||
|
||||
### Matrix[numI][numJ][numK][3] riGetCellCenters([CaseId], GridIndex)
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetCellCenters\n");
|
||||
%! CellCenters1 = riGetCellCenters(0);
|
||||
%! CellCenters2 = riGetCellCenters(1, 0);
|
||||
%! assert( ndims (CellCenters1) == 4);
|
||||
%! [ni, nj, nk, idx ] = size(CellCenters1);
|
||||
%! assert(idx == 3);
|
||||
%! assert(ni == 139);
|
||||
%! assert(nj == 48);
|
||||
%! assert(nk == 9);
|
||||
%! assert(CellCenters1(62,30,1, 1), 3489.2, 0.1);
|
||||
%! assert(CellCenters1(62,30,1, 2), 1.5909e+004, 0.1);
|
||||
%! assert(CellCenters1(62,30,1, 3), -5458.8, 0.1);
|
||||
%! assert(CellCenters1 == CellCenters2);
|
||||
|
||||
|
||||
|
||||
### Matrix[ActiveCells][3] riGetActiveCellCenters([CaseId], [PorosityModel = "Matrix"|"Fracture"])
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetActiveCellCenters\n");
|
||||
%! ActiveCellCenters1 = riGetActiveCellCenters();
|
||||
%! ActiveCellCenters2 = riGetActiveCellCenters("Matrix");
|
||||
%! ActiveCellCenters3 = riGetActiveCellCenters(1, "Matrix");
|
||||
|
||||
%! assert (rows(ActiveCellCenters1), rows(riGetActiveCellInfo()));
|
||||
%! assert (columns(ActiveCellCenters1) == 3);
|
||||
%! assert (ActiveCellCenters1(500,:) ,[3493.7, 9184.6, -6074.4], [0.1, 0.1, 0.1]);
|
||||
%! assert (ActiveCellCenters1 == ActiveCellCenters2);
|
||||
%! assert (ActiveCellCenters1 == ActiveCellCenters3);
|
||||
|
||||
|
||||
### Matrix[numI][numJ][numK][8][3] riGetCellCorners([CaseId], GridIndex)
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetCellCorners\n");
|
||||
%! CellCorners1 = riGetCellCorners(0);
|
||||
%! CellCorners2 = riGetCellCorners(1, 0);
|
||||
|
||||
%! assert( ndims (CellCorners1) == 5);
|
||||
%! [ni, nj, nk, cidx, idx ] = size(CellCorners1);
|
||||
%! assert(idx == 3);
|
||||
%! assert(cidx == 8);
|
||||
%! assert(ni == 139);
|
||||
%! assert(nj == 48);
|
||||
%! assert(nk == 9);
|
||||
%! assert(CellCorners1(62,30,1, 1, 1), 3207.4, 0.1);
|
||||
%! assert(CellCorners1(62,30,1, 1, 2), 1.5781e+004, 1);
|
||||
%! assert(CellCorners1(62,30,1, 1, 3), -5466.1, 0.1);
|
||||
%! assert (CellCorners1 == CellCorners2);
|
||||
|
||||
|
||||
### Matrix[ActiveCells][8][3] riGetActiveCellCorners([CaseId], [PorosityModel = "Matrix"|"Fracture"])
|
||||
%!test
|
||||
%! printf ("===== Testing ====> riGetActiveCellCorners\n");
|
||||
%! ActiveCellCorners1 = riGetActiveCellCorners();
|
||||
%! ActiveCellCorners2 = riGetActiveCellCorners(1);
|
||||
%! ActiveCellCorners3 = riGetActiveCellCorners(1, "Matrix");
|
||||
%! ActiveCellCorners4 = riGetActiveCellCorners("Matrix");
|
||||
|
||||
%! assert( ndims (ActiveCellCorners1) == 3);
|
||||
%! [nactive, cidx, idx ] = size(ActiveCellCorners1);
|
||||
%! assert(idx == 3);
|
||||
%! assert(cidx == 8);
|
||||
%! assert(nactive , rows(riGetActiveCellInfo()));
|
||||
|
||||
%! assert(ActiveCellCorners1(500,1, 1), 3207.2, 0.1);
|
||||
%! assert(ActiveCellCorners1(500,1, 2), 9080.7, 0.1);
|
||||
%! assert(ActiveCellCorners1(500,1, 3), -6076.8, 0.1);
|
||||
%! assert (ActiveCellCorners1 , ActiveCellCorners2);
|
||||
%! assert (ActiveCellCorners1 , ActiveCellCorners3);
|
||||
%! assert (ActiveCellCorners1 , ActiveCellCorners4);
|
||||
|
||||
### Vector[WellNames] riGetWellNames([CaseId])
|
||||
%!xtest
|
||||
%! printf ("===== Testing ====> riGetWellNames\n");
|
||||
%! WellNames1 = riGetWellNames();
|
||||
%! WellNames2 = riGetWellNames(1);
|
||||
%! assert (rows(WellNames1), 113);
|
||||
%! assert (WellNames1{113}, "P20-03");
|
||||
%! assert (rows(WellNames1) == rows(WellNames2));
|
||||
%! assert (WellNames2{113}, "P20-03");
|
||||
|
||||
### Vector[WellCellInfo] riGetWellCells([CaseId], WellName, TimeStep)
|
||||
%!xtest
|
||||
%! printf ("===== Testing ====> riGetWellCells\n");
|
||||
%! WellNames1 = riGetWellNames();
|
||||
%! WellCellInfos1 = riGetWellCells(1, WellNames1{1}, 3);
|
||||
%! WellCellInfos2 = riGetWellCells(WellNames1{1}, 3);
|
||||
|
||||
|
||||
### Vector[WellStatus] riGetWellStatus ([CaseId], WellName, [RequestedTimeSteps])
|
||||
%!xtest
|
||||
%! printf ("===== Testing ====> riGetWellStatus\n");
|
||||
%! WellNames1 = riGetWellNames();
|
||||
%! WellStatuses1 = riGetWellStatus(1, WellNames1{1}, [1,3]);
|
||||
%! disp(WellStatuses1(1));
|
||||
%! WellStatuses2 = riGetWellStatus( WellNames1{1}, [1,3]);
|
||||
%! WellStatuses3 = riGetWellStatus(WellNames1{1});
|
||||
|
||||
endif
|
154
OctavePlugin/OctaveScripts/ResInsightIterfaceUnitTest.m
Normal file
154
OctavePlugin/OctaveScripts/ResInsightIterfaceUnitTest.m
Normal file
@ -0,0 +1,154 @@
|
||||
### The case with caseid 1 has to be selected/active in ResInsight when running this test-script
|
||||
### Coarsening and Dual porosity is not exercised by this tes yet. We need models
|
||||
|
||||
if (1)
|
||||
test OctaveInterfaceTest.m
|
||||
else
|
||||
|
||||
### CaseInfo riGetCurrentCase()
|
||||
printf ("===== Testing ====> riGetCurrentCase\n");
|
||||
caseInfo = riGetCurrentCase();
|
||||
disp(caseInfo);
|
||||
|
||||
|
||||
### Vector[CaseInfo] riGetSelectedCases()
|
||||
printf ("===== Testing ====> riGetSelectedCases\n");
|
||||
caseInfoVector1 = riGetSelectedCases();
|
||||
disp(caseInfoVector1);
|
||||
|
||||
if(0)
|
||||
|
||||
### Vector[CaseGroupInfo] riGetCaseGroups()
|
||||
printf ("===== Testing ====> riGetCaseGroups\n");
|
||||
caseGroupInfoVector = riGetCaseGroups();
|
||||
|
||||
### Vector[CaseInfo] riGetCases([CaseGroupId])
|
||||
printf ("===== Testing ====> riGetCases\n");
|
||||
caseinfoVector2 = riGetCases();
|
||||
caseinfoVector3 = riGetCases(caseGroupInfoVector(2).CaseGroupId);
|
||||
|
||||
### Matrix[numActiveCells][9] riGetActiveCellInfo([CaseId], [PorosityModel = "Matrix"|"Fracture"] )
|
||||
printf ("===== Testing ====> riGetActiveCellInfo\n");
|
||||
ACInfo1 = riGetActiveCellInfo();
|
||||
ACInfo2 = riGetActiveCellInfo("Matrix");
|
||||
ACInfo3 = riGetActiveCellInfo(1, "Matrix");
|
||||
|
||||
### Matrix[numCoarseGroups][6] riGetCoarseningInfo([CaseId])
|
||||
printf ("===== Testing ====> riGetCoarseningInfo\n");
|
||||
CoarseInfo1 = riGetCoarseningInfo();
|
||||
CoarseInfo2 = riGetCoarseningInfo(1);
|
||||
|
||||
### Matrix[numGrids][3] riGetGridDimensions([CaseId])
|
||||
printf ("===== Testing ====> riGetGridDimensions\n");
|
||||
GridDims1 = riGetGridDimensions();
|
||||
GridDims2 = riGetGridDimensions(1);
|
||||
|
||||
### Vector[TimeStepDate] riGetTimestepDates([CaseId])
|
||||
printf ("===== Testing ====> riGetTimestepDates\n");
|
||||
TimeStepDates1 = riGetTimeStepDates();
|
||||
TimeStepDates2 = riGetTimeStepDates(1);
|
||||
|
||||
### Vector[DecimalDay] riGetTimestepDays([CaseId])
|
||||
printf ("===== Testing ====> riGetTimestepDays\n");
|
||||
TimeStepDays1 = riGetTimeStepDays();
|
||||
TimeStepDays2 = riGetTimeStepDays(1);
|
||||
|
||||
### Vector[PropertyInfo] riGetPropertyNames([CaseId] ], [PorosityModel = "Matrix"|"Fracture"])
|
||||
printf ("===== Testing ====> riGetPropertyNames\n");
|
||||
PropertyInfos1 = riGetPropertyNames();
|
||||
PropertyInfos2 = riGetPropertyNames(1);
|
||||
PropertyInfos3 = riGetPropertyNames("Matrix");
|
||||
PropertyInfos4 = riGetPropertyNames(1, "Matrix");
|
||||
|
||||
### Matrix[numActiveCells][numTimestepsRequested] riGetActiveCellProperty([CaseId], PropertyName, [RequestedTimeSteps], [PorosityModel = "Matrix"|"Fracture"])
|
||||
printf ("===== Testing ====> riGetActiveCellProperty\n");
|
||||
ActivePropData1 = riGetActiveCellProperty("SOIL");
|
||||
ActivePropData2 = riGetActiveCellProperty("SOIL", "Matrix");
|
||||
ActivePropData3 = riGetActiveCellProperty("SOIL", [1,3]);
|
||||
ActivePropData4 = riGetActiveCellProperty("SOIL", [1,3], "Matrix");
|
||||
|
||||
ActivePropData5 = riGetActiveCellProperty(1, "SOIL");
|
||||
ActivePropData6 = riGetActiveCellProperty(1, "SOIL", [1,3]);
|
||||
ActivePropData7 = riGetActiveCellProperty(1, "SOIL", [1,3], "Matrix");
|
||||
ActivePropData8 = riGetActiveCellProperty(1, "SOIL", "Matrix");
|
||||
|
||||
### Matrix[numI][numJ][numK][numTimestepsRequested] riGetGridProperty([CaseId], GridIndex , PropertyName, [RequestedTimeSteps], [PorosityModel = "Matrix"|"Fracture"])
|
||||
printf ("===== Testing ====> riGetGridProperty\n");
|
||||
GridProps1 = riGetGridProperty( 0 , "SOIL" );
|
||||
GridProps2 = riGetGridProperty( 0 , "SOIL", [1,3]);
|
||||
GridProps3 = riGetGridProperty( 0 , "SOIL", [1,3], "Matrix");
|
||||
GridProps4 = riGetGridProperty( 0 , "SOIL", "Matrix");
|
||||
GridProps5 = riGetGridProperty(1, 0 , "SOIL" );
|
||||
GridProps6 = riGetGridProperty(1, 0 , "SOIL", [1,3]);
|
||||
GridProps7 = riGetGridProperty(1, 0 , "SOIL", [1,3], "Matrix");
|
||||
GridProps8 = riGetGridProperty(1, 0 , "SOIL", "Matrix");
|
||||
|
||||
|
||||
### riSetActiveCellProperty( Matrix[numActiveCells][numTimeSteps], [CaseId], PropertyName, [TimeStepIndices], [PorosityModel = "Matrix"|"Fracture"])
|
||||
printf ("===== Testing ====> riSetActiveCellProperty\n");
|
||||
riSetActiveCellProperty( ActivePropData1, "PropertyName1" );
|
||||
|
||||
riSetActiveCellProperty( ActivePropData3, "PropertyName2", [1,3]);
|
||||
riSetActiveCellProperty( ActivePropData3, "PropertyName3", [1,3], "Matrix");
|
||||
riSetActiveCellProperty( ActivePropData1, "PropertyName4", "Matrix");
|
||||
riSetActiveCellProperty( ActivePropData1, 1, "PropertyName5" );
|
||||
riSetActiveCellProperty( ActivePropData3, 1, "PropertyName6", [1,3]);
|
||||
riSetActiveCellProperty( ActivePropData3, 1, "PropertyName7", [1,3], "Matrix");
|
||||
riSetActiveCellProperty( ActivePropData1, 1, "PropertyName8", "Matrix");
|
||||
|
||||
### riSetGridProperty( Matrix[numI][numJ][numK][numTimeSteps], [CaseId], GridIndex, PropertyName, [TimeStepIndices], [PorosityModel = "Matrix"|"Fracture"])
|
||||
printf ("===== Testing ====> riSetGridProperty\n");
|
||||
riSetGridProperty( GridProps1, 0, "PropertyName11" );
|
||||
riSetGridProperty( GridProps2, 0, "PropertyName12", [1,3]);
|
||||
riSetGridProperty( GridProps2, 0, "PropertyName13", [1,3], "Matrix");
|
||||
riSetGridProperty( GridProps1, 0, "PropertyName14", "Matrix");
|
||||
riSetGridProperty( GridProps1, 1, 0, "PropertyName15" );
|
||||
riSetGridProperty( GridProps2, 1, 0, "PropertyName16", [1,3]);
|
||||
riSetGridProperty( GridProps2, 1, 0, "PropertyName17", [1,3], "Matrix");
|
||||
riSetGridProperty( GridProps1, 1, 0, "PropertyName18", "Matrix");
|
||||
|
||||
|
||||
### Matrix[numI][numJ][numK][3] riGetCellCenters([CaseId], GridIndex)
|
||||
printf ("===== Testing ====> riGetCellCenters\n");
|
||||
CellCenters1 = riGetCellCenters(0);
|
||||
CellCenters2 = riGetCellCenters(1, 0);
|
||||
|
||||
### Matrix[ActiveCells][3] riGetActiveCellCenters([CaseId], [PorosityModel = "Matrix"|"Fracture"])
|
||||
printf ("===== Testing ====> riGetActiveCellCenters\n");
|
||||
ActiveCellCenters1 = riGetActiveCellCenters();
|
||||
ActiveCellCenters2 = riGetActiveCellCenters("Matrix");
|
||||
ActiveCellCenters3 = riGetActiveCellCenters(1, "Matrix");
|
||||
|
||||
### Matrix[numI][numJ][numK][8][3] riGetCellCorners([CaseId], GridIndex)
|
||||
printf ("===== Testing ====> riGetCellCorners\n");
|
||||
CellCorners1 = riGetCellCorners(0);
|
||||
CellCorners2 = riGetCellCorners(1, 0);
|
||||
|
||||
### Matrix[ActiveCells][8][3] riGetActiveCellCorners([CaseId], [PorosityModel = "Matrix"|"Fracture"])
|
||||
printf ("===== Testing ====> riGetActiveCellCorners\n");
|
||||
ActiveCellCorners1 = riGetActiveCellCorners();
|
||||
ActiveCellCorners2 = riGetActiveCellCorners(1);
|
||||
ActiveCellCorners3 = riGetActiveCellCorners(1, "Matrix");
|
||||
ActiveCellCorners4 = riGetActiveCellCorners("Matrix");
|
||||
|
||||
### Vector[WellNames] riGetWellNames([CaseId])
|
||||
printf ("===== Testing ====> riGetWellNames\n");
|
||||
|
||||
WellNames1 = riGetWellNames();
|
||||
WellNames2 = riGetWellNames(1);
|
||||
|
||||
### Vector[WellCellInfo] riGetWellCells([CaseId], WellName, TimeStep)
|
||||
printf ("===== Testing ====> riGetWellCells\n");
|
||||
WellCellInfos1 = riGetWellCells(1, WellNames1(1,:), 3);
|
||||
WellCellInfos2 = riGetWellCells(WellNames1(1,:), 3);
|
||||
|
||||
|
||||
### Vector[WellStatus] riGetWellStatus ([CaseId], WellName, [RequestedTimeSteps])
|
||||
printf ("===== Testing ====> riGetWellStatus\n");
|
||||
WellStatuses1 = riGetWellStatus(1, WellNames1(1,:), [1,3]);
|
||||
disp(WellStatuses1(1));
|
||||
WellStatuses2 = riGetWellStatus( WellNames1(1,:), [1,3]);
|
||||
WellStatuses3 = riGetWellStatus(WellNames1(1,:));
|
||||
|
||||
endif
|
||||
endif
|
@ -168,8 +168,8 @@ DEFUN_DLD (riGetActiveCellProperty, args, nargout,
|
||||
}
|
||||
|
||||
// Check if we have a Requested TimeSteps
|
||||
|
||||
if (!(nargin > argIndices[2] && args(argIndices[2]).is_matrix_type()))
|
||||
|
||||
if (!(nargin > argIndices[2] && args(argIndices[2]).is_matrix_type() && !args(argIndices[2]).is_string()))
|
||||
{
|
||||
argIndices[2] = -1;
|
||||
for (size_t aIdx = 3; aIdx < argIndices.size(); ++aIdx)
|
||||
|
@ -46,8 +46,8 @@ void getCoarseningInfo(int32NDArray& coarseningInfo, const QString &hostName, qu
|
||||
quint64 boxCount = byteCount / (6 * sizeof(qint32));
|
||||
|
||||
dim_vector dv (1, 1);
|
||||
dv(0) = 6;
|
||||
dv(1) = boxCount;
|
||||
dv(0) = boxCount;
|
||||
dv(1) = 6;
|
||||
|
||||
coarseningInfo.resize(dv);
|
||||
|
||||
@ -67,12 +67,12 @@ void getCoarseningInfo(int32NDArray& coarseningInfo, const QString &hostName, qu
|
||||
socketStream >> k1;
|
||||
socketStream >> k2;
|
||||
|
||||
coarseningInfo(0, i) = i1;
|
||||
coarseningInfo(1, i) = i2;
|
||||
coarseningInfo(2, i) = j1;
|
||||
coarseningInfo(3, i) = j2;
|
||||
coarseningInfo(4, i) = k1;
|
||||
coarseningInfo(5, i) = k2;
|
||||
coarseningInfo(i, 0) = i1;
|
||||
coarseningInfo(i, 1) = i2;
|
||||
coarseningInfo(i, 2) = j1;
|
||||
coarseningInfo(i, 3) = j2;
|
||||
coarseningInfo(i, 4) = k1;
|
||||
coarseningInfo(i, 5) = k2;
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -168,7 +168,7 @@ DEFUN_DLD (riGetGridProperty, args, nargout,
|
||||
|
||||
// Check if we have a Requested TimeSteps
|
||||
|
||||
if (!(nargin > argIndices[3] && args(argIndices[3]).is_matrix_type()))
|
||||
if (!(nargin > argIndices[3] && args(argIndices[3]).is_matrix_type() && !args(argIndices[3]).is_string()))
|
||||
{
|
||||
argIndices[3] = -1;
|
||||
for (size_t aIdx = 3; aIdx < argIndices.size(); ++aIdx)
|
||||
|
@ -71,7 +71,7 @@ void getWellCells( std::vector<int>& cellIs,
|
||||
quint64 cellCount;
|
||||
socketStream >> cellCount;
|
||||
|
||||
octave_stdout << "riGetWellCells2: Num cells = " << cellCount << std::endl;
|
||||
octave_stdout << "riGetWellCells: Number of cells in well " << wellName.toLatin1().data() << " : " << cellCount << std::endl;
|
||||
|
||||
cellIs .reserve(cellCount);
|
||||
cellJs .reserve(cellCount);
|
||||
|
@ -112,16 +112,13 @@ DEFUN_DLD (riGetWellNames, args, nargout,
|
||||
|
||||
// Create cells with N items for each field in the data structure
|
||||
|
||||
//charMatrix octaveWellNames;
|
||||
string_vector octaveWellNames;
|
||||
for (size_t i = 0; i < caseCount; i++)
|
||||
{
|
||||
octaveWellNames.append(wellNames[i].toStdString());
|
||||
}
|
||||
|
||||
// Build a map between the field name and field cell values
|
||||
|
||||
return octave_value(octaveWellNames);
|
||||
return octave_value(Cell(octaveWellNames));
|
||||
}
|
||||
|
||||
return octave_value();
|
||||
|
@ -78,7 +78,7 @@ void setEclipseProperty(const Matrix& propertyFrames, const QString &hostName, q
|
||||
|
||||
if (socket.bytesToWrite() && socket.state() != QAbstractSocket::ConnectedState)
|
||||
{
|
||||
error("riSetActiveCellProperty : ResInsight refused to accept the data. Maybe the dimentions or porosity model is wrong");
|
||||
error("riSetActiveCellProperty : ResInsight refused to accept the data. Maybe the dimensions or porosity model is wrong");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -92,6 +92,8 @@ DEFUN_DLD (riSetActiveCellProperty, args, nargout,
|
||||
"\n"
|
||||
"Interprets the supplied matrix as a property set defined for the active cells in the case, "
|
||||
"and puts the data into ResInsight as a \"Generated\" property with the name \"PropertyName\"."
|
||||
"The \"TimeStepIndices\" argument is used to \"label\" all the time steps present in the supplied data matrix,"
|
||||
"and must thus be complete. The time step data will then be put into ResInsight at the time steps requested."
|
||||
"If the CaseId is not defined, ResInsight’s Current Case is used."
|
||||
)
|
||||
{
|
||||
@ -146,7 +148,7 @@ DEFUN_DLD (riSetActiveCellProperty, args, nargout,
|
||||
|
||||
// Check if we have a Requested TimeSteps
|
||||
|
||||
if (!(nargin > argIndices[3] && args(argIndices[3]).is_matrix_type()))
|
||||
if (!(nargin > argIndices[3] && args(argIndices[3]).is_matrix_type() && !args(argIndices[3]).is_string()))
|
||||
{
|
||||
argIndices[3] = -1;
|
||||
for (size_t aIdx = 4; aIdx < argIndices.size(); ++aIdx)
|
||||
|
@ -112,6 +112,7 @@ DEFUN_DLD (riSetGridProperty, args, nargout,
|
||||
"\triSetGridProperty( Matrix[numI][numJ][numK][numTimeSteps], [CaseId], GridIndex, PropertyName, [TimeStepIndices], [PorosityModel = \"Matrix\"|\"Fracture\"] ) \n"
|
||||
"\n"
|
||||
"Interprets the supplied matrix as a property set defined for all cells in one of the grids in a case, and puts the data into ResInsight as a \"Generated\" property with the name \"PropertyName\".\n"
|
||||
"The \"TimeStepIndices\" argument is used to \"label\" all the time steps present in the supplied data matrix, and must thus be complete. The time step data will then be put into ResInsight at the time steps requested."
|
||||
"If the CaseId is not defined, ResInsight’s Current Case is used.\n"
|
||||
)
|
||||
{
|
||||
@ -176,7 +177,7 @@ DEFUN_DLD (riSetGridProperty, args, nargout,
|
||||
|
||||
// Check if we have a Requested TimeSteps
|
||||
|
||||
if (!(nargin > argIndices[4] && args(argIndices[4]).is_matrix_type()))
|
||||
if (!(nargin > argIndices[4] && args(argIndices[4]).is_matrix_type() && !args(argIndices[4]).is_string()))
|
||||
{
|
||||
argIndices[4] = -1;
|
||||
for (size_t aIdx = 5; aIdx < argIndices.size(); ++aIdx)
|
||||
|
@ -40,7 +40,7 @@ namespace riOctavePlugin
|
||||
|
||||
// Octave data structure : CaseGroupInfo
|
||||
char caseGroupInfo_CaseGroupId[] = "CaseGroupId";
|
||||
char caseGroupInfo_CaseGroupName[] = "CaseName";
|
||||
char caseGroupInfo_CaseGroupName[] = "CaseGroupName";
|
||||
|
||||
// Octave data structure : WellCellInfo
|
||||
char wellCellInfo_I[] = "I";
|
||||
|
34
README
34
README
@ -1,26 +1,36 @@
|
||||
These are the release notes for ResInsight.
|
||||
This is the README file for ResInsight.
|
||||
|
||||
ResInsight is a 3D viewer and post processing tool for reservoir models. It has been co-developed by Statoil and Ceetron with the aim to provide a versatile tool for professionals who need to visualize and process reservoir models. The software is copyrighted by Ceetron and Statoil and licensed under GPL 3+. See COPYING for details.
|
||||
ResInsight is a 3D viewer and post processing tool for reservoir models. It has been co-developed by Statoil and Ceetron AS / Ceetron Solutions AS with the aim to provide a versatile tool for professionals who need to visualize and process reservoir models. The software is copyrighted by Ceetron and Statoil and licensed under GPL 3+. See COPYING for details.
|
||||
|
||||
DEPENDENCIES
|
||||
ResInsight uses the Ensambles/ert library to access eclipse result files, and the two projects collaborates closely. The source code of the approved ert library version is embedded in the ResInsight source code tree, making downloading and building simple.
|
||||
ResInsight also features an interface to Octave, making it possible to retrieve data from ResInsight, process them using Octave, and write them back into ResInsight for viewing. If you want to build ResInsight with this feature, you need to install Octave.
|
||||
|
||||
http://www.gnu.org/software/octave/
|
||||
https://github.com/Ensembles/ert
|
||||
|
||||
ON WHAT PLATFORMS DOES IT RUN?
|
||||
ResInsight is designed cross-platform from the start. Efforts have been made to ensure that code will compile and run on linux and windows platforms. It will probably also compile and run on osx should anybody be interested in that.
|
||||
ResInsight is designed cross-platform from the start. Efforts have been made to ensure that code will compile and run on linux and windows platforms, but the tested platforms are currently 64 bit RHE 5, RHE 6 and Windows 7.
|
||||
|
||||
There has been attemts to make ResInsight build and run on OSX as well, but the tweaks needed (submitted by Roland Kaufmann) is not yet incorporated.
|
||||
|
||||
DOCUMENTATION
|
||||
No efforts to provide documentation has been made yet.
|
||||
|
||||
DOWNLOADING RESINSIGHT
|
||||
git clone git://github.com/OPM/ResInsight.git
|
||||
git clone git://github.com/OPM/ResInsight.git
|
||||
|
||||
CONTRIBUTION
|
||||
Please use master branch for contributions and pull requests. Please do not use branch 'internal' for contributions.
|
||||
Contributions are very welcome, although it might take some time for the team to accept pull requests that is not in the main line of the projects focus. Please use the dev branch for contributions and pull requests, as it is the branch dedicated to the day to day development. The master branch is used as a branch for distributing the latest stable release.
|
||||
Release branches that might pop up are dedicated bug fix branches for the release in question.
|
||||
|
||||
BUILDING RESINSIGHT - Linux
|
||||
ResInsight uses the cmake build system and requires cmake version 2.8 or higher. Moreover, you need version 4.7.3 of Qt or newer, look below for dependecy list. An out-of-tree build is typically done with
|
||||
mkdir ResInsight/build
|
||||
cd ResInsight/build
|
||||
cmake ..
|
||||
make
|
||||
make install
|
||||
mkdir ResInsight/build
|
||||
cd ResInsight/build
|
||||
cmake ..
|
||||
make
|
||||
make install
|
||||
You will find the ResInsight binary under the Install directory in your build directory.
|
||||
|
||||
BUILDING RESINSIGHT - Windows
|
||||
@ -32,5 +42,5 @@ Set the build variables and click "Configure" again.
|
||||
Click "Generate", and a project file will be created in the build directory <ResInsight-build-folder>
|
||||
|
||||
DEPENDENCIES FOR DEBIAN BASED DISTRIBUTIONS
|
||||
sudo apt-get install git cmake build-essential octave octave-headers qt4-dev-tools
|
||||
If you are running Ubuntu 12.10 or newer, you will need to replace octave-headers with liboctave-dev in the line above.
|
||||
sudo apt-get install git cmake build-essential octave octave-headers qt4-dev-tools
|
||||
If you are running Ubuntu 12.10 or newer, you will need to replace octave-headers with liboctave-dev in the line above.
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
set(CMAKE_MAJOR_VERSION 0)
|
||||
set(CMAKE_MINOR_VERSION 9)
|
||||
set(CMAKE_PATCH_VERSION 29)
|
||||
set(CMAKE_PATCH_VERSION 30)
|
||||
|
||||
set(PRODUCTVER ${CMAKE_MAJOR_VERSION},${CMAKE_MINOR_VERSION},0,${CMAKE_PATCH_VERSION})
|
||||
set(STRPRODUCTVER ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION})
|
||||
|
2957
TestModels/OctaveUnitTestProject.rsp
Normal file
2957
TestModels/OctaveUnitTestProject.rsp
Normal file
File diff suppressed because it is too large
Load Diff
49
ThirdParty/Ert/devel/CMakeLists.txt
vendored
49
ThirdParty/Ert/devel/CMakeLists.txt
vendored
@ -10,10 +10,13 @@ option( BUILD_TESTS "Should the tests be built" OFF)
|
||||
option( BUILD_APPLICATIONS "Should we build small utility applications" OFF)
|
||||
option( BUILD_ECL_SUMMARY "Build the commandline application ecl_summary" OFF)
|
||||
option( BUILD_PYTHON "Run py_compile on the python wrappers" OFF)
|
||||
option( BUILD_SHARED_LIBS "Build shared libraries" ON )
|
||||
option( INSTALL_ERT "Should anything be installed when issuing make install?" ON)
|
||||
|
||||
option( ERT_BUILD_GUI "Should the pyQt based gui be compiled and installed" OFF )
|
||||
option( ERT_USE_OPENMP "Use OpenMP - currently only in EclGrid" ON)
|
||||
|
||||
include( CheckFunctionExists )
|
||||
include( CheckTypeSize )
|
||||
ENABLE_TESTING()
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
@ -26,6 +29,7 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
add_definitions( -DWINDOWS_LFS )
|
||||
endif()
|
||||
|
||||
|
||||
# Treat warnings as errors if not on Windows
|
||||
if (ERT_WINDOWS)
|
||||
set( CMAKE_C_FLAGS "-O2" )
|
||||
@ -35,29 +39,42 @@ else()
|
||||
set( CMAKE_CXX_FLAGS "-g -Wall -O2 ")
|
||||
endif()
|
||||
|
||||
if (ERT_USE_OPENMP)
|
||||
find_package(OpenMP)
|
||||
if (OPENMP_FOUND)
|
||||
message(STATUS "Enabling OpenMP support")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_SHARED_LINKER_FLAGS}")
|
||||
else()
|
||||
message(STATUS "OpenMP package not found - OpenMP disabled")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
include(cmake/ert_check.cmake)
|
||||
include(cmake/ert_find.cmake)
|
||||
include(cmake/Modules/UseMultiArch.cmake)
|
||||
include(cmake/ert_link.cmake)
|
||||
|
||||
|
||||
set( INSTALL_GROUP "" CACHE STRING "Group to install as - blank to install as current group")
|
||||
set(INSTALL_GROUP "" CACHE STRING "Group to install as - blank to install as current group")
|
||||
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||
|
||||
if (MSVC)
|
||||
set( LIBRARY_TYPE STATIC )
|
||||
set( SHARED_LIB OFF )
|
||||
else()
|
||||
if (INSTALL_ERT)
|
||||
set( LIBRARY_TYPE SHARED )
|
||||
set( SHARED_LIB ON )
|
||||
else()
|
||||
set( LIBRARY_TYPE STATIC )
|
||||
set( SHARED_LIB OFF )
|
||||
endif(INSTALL_ERT)
|
||||
endif()
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
set( LIBRARY_TYPE SHARED )
|
||||
else()
|
||||
set( LIBRARY_TYPE STATIC )
|
||||
if (BUILD_ERT)
|
||||
message(FATAL_ERROR "The full ERT application must be built with shared libraries")
|
||||
endif()
|
||||
if (BUILD_PYTHON)
|
||||
message(FATAL_ERROR "The Python wrappers require shared libraries")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
add_definitions( -D__func__="\\"????\\"")
|
||||
@ -67,12 +84,10 @@ endif()
|
||||
if (ERT_LINUX)
|
||||
set( NEED_LIBM TRUE )
|
||||
set( LINK_STATIC FALSE )
|
||||
set( NEED_LIBDL ON )
|
||||
add_definitions( -DHAVE_PROC )
|
||||
else()
|
||||
set( NEED_LIBM FALSE )
|
||||
set( LINK_STATIC TRUE )
|
||||
set( NEED_LIBDL OFF )
|
||||
endif()
|
||||
|
||||
|
||||
@ -105,8 +120,6 @@ add_subdirectory( libecl_well )
|
||||
#-----------------------------------------------------------------
|
||||
if (BUILD_ERT)
|
||||
#-----------------------------------------------------------------
|
||||
option(USE_LSF "Include support for LSF" ON)
|
||||
|
||||
include_directories( ${PROJECT_SOURCE_DIR}/libconfig/include )
|
||||
add_subdirectory( libconfig )
|
||||
|
||||
|
21
ThirdParty/Ert/devel/cmake/Tests/test_mktime_before1970.c
vendored
Normal file
21
ThirdParty/Ert/devel/cmake/Tests/test_mktime_before1970.c
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
struct tm ts;
|
||||
ts.tm_sec = 0;
|
||||
ts.tm_min = 0;
|
||||
ts.tm_hour = 0;
|
||||
ts.tm_mday = 1;
|
||||
ts.tm_mon = 0;
|
||||
ts.tm_year = 0;
|
||||
ts.tm_isdst = -1;
|
||||
{
|
||||
time_t t = mktime( &ts );
|
||||
if (t == -1)
|
||||
exit(1);
|
||||
else
|
||||
exit(0);
|
||||
}
|
||||
}
|
71
ThirdParty/Ert/devel/cmake/create_cmakelists.py
vendored
Normal file
71
ThirdParty/Ert/devel/cmake/create_cmakelists.py
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from os import listdir
|
||||
from os.path import isfile, join, isdir
|
||||
import sys
|
||||
|
||||
|
||||
|
||||
def findFilesAndDirectories(directory):
|
||||
all_files = listdir(directory)
|
||||
files = []
|
||||
directories = []
|
||||
for f in all_files:
|
||||
path = join(directory, f)
|
||||
if isfile(path) and not f == "CMakeLists.txt":
|
||||
files.append(f)
|
||||
if isdir(path):
|
||||
directories.append(f)
|
||||
|
||||
return sorted(files), sorted(directories)
|
||||
|
||||
|
||||
def findRelativeModulePath(directory):
|
||||
"""@type directory: str"""
|
||||
index = directory.rfind("python/")
|
||||
index += len("python/")
|
||||
return directory[index:len(directory)]
|
||||
|
||||
def createPythonSources(files):
|
||||
result = ""
|
||||
|
||||
if len(files) > 0:
|
||||
result = "set(PYTHON_SOURCES\n"
|
||||
|
||||
files = [f for f in files if f.endswith(".py")]
|
||||
|
||||
for f in files:
|
||||
result += " " + str(f) + "\n"
|
||||
|
||||
if len(files) > 0:
|
||||
result += ")"
|
||||
|
||||
return result
|
||||
|
||||
def addSubDirectories(directories):
|
||||
result = ""
|
||||
|
||||
for d in directories:
|
||||
result += "add_subdirectory(" + str(d) + ")\n"
|
||||
|
||||
return result
|
||||
|
||||
def addPythonPackage(relative_module_path):
|
||||
module_name = ".".join(relative_module_path.split("/"))
|
||||
template = "add_python_package(\"Python %s\" ${PYTHON_INSTALL_PREFIX}/%s \"${PYTHON_SOURCES}\" True)"
|
||||
|
||||
return template % (module_name, relative_module_path)
|
||||
|
||||
|
||||
files, directories = findFilesAndDirectories(sys.argv[1])
|
||||
module_path = findRelativeModulePath(sys.argv[1])
|
||||
|
||||
output_file = join(sys.argv[1], "CMakeLists.txt")
|
||||
with open(output_file, "w+") as text_file:
|
||||
text_file.write(createPythonSources(files))
|
||||
text_file.write("\n\n")
|
||||
text_file.write(addPythonPackage(module_path))
|
||||
text_file.write("\n\n")
|
||||
text_file.write(addSubDirectories(directories))
|
||||
|
||||
|
21
ThirdParty/Ert/devel/cmake/ert_check.cmake
vendored
21
ThirdParty/Ert/devel/cmake/ert_check.cmake
vendored
@ -43,6 +43,18 @@ if (HAVE_GETUID)
|
||||
add_definitions( -DHAVE_GETUID )
|
||||
endif()
|
||||
|
||||
check_function_exists( _chdir HAVE_WINDOWS_CHDIR)
|
||||
if (HAVE_WINDOWS_CHDIR)
|
||||
add_definitions( -DHAVE_WINDOWS_CHDIR)
|
||||
else()
|
||||
check_function_exists( chdir HAVE_CHDIR)
|
||||
if (HAVE_CHDIR)
|
||||
add_definitions( -DHAVE_CHDIR)
|
||||
else()
|
||||
message(FATAL_ERROR "Could not find chdir() / _chdir() functions")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
check_function_exists( localtime_r HAVE_LOCALTIME_R )
|
||||
if (HAVE_LOCALTIME_R)
|
||||
add_definitions( -DHAVE_LOCALTIME_R )
|
||||
@ -128,5 +140,14 @@ if (ISREG_POSIX)
|
||||
add_definitions( -DHAVE_ISREG )
|
||||
endif()
|
||||
|
||||
check_type_size(time_t SIZE_OF_TIME_T)
|
||||
if (${SIZE_OF_TIME_T} EQUAL 8)
|
||||
try_run( RUN_RESULT COMPILE_RESULT ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_mktime_before1970.c )
|
||||
if (RUN_RESULT)
|
||||
add_defintions( -DTIME_T_64BIT_ACCEPT_PRE1970 )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set( CMAKE_C_FLAGS ${CMAKE_C_FLAGS_main} )
|
||||
set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_main} )
|
||||
|
||||
|
15
ThirdParty/Ert/devel/cmake/ert_find.cmake
vendored
15
ThirdParty/Ert/devel/cmake/ert_find.cmake
vendored
@ -1,3 +1,15 @@
|
||||
set(NEED_LIBDL OFF)
|
||||
find_library( DL_LIBRARY NAMES dl )
|
||||
find_path( DLFUNC_HEADER dlfcn.h )
|
||||
if (DL_LIBRARY AND DLFUNC_HEADER)
|
||||
set(CMAKE_REQUIRED_LIBRARIES dl)
|
||||
|
||||
check_function_exists( dladdr HAVE_DLADDR )
|
||||
if (HAVE_DLADDR)
|
||||
add_definitions( -DHAVE_DLADDR )
|
||||
set(NEED_LIBDL ON)
|
||||
endif()
|
||||
endif()
|
||||
#-----------------------------------------------------------------
|
||||
find_library( ZLIB_LIBRARY NAMES z )
|
||||
find_path( ZLIB_HEADER zlib.h /usr/include )
|
||||
@ -66,6 +78,9 @@ if (GETOPT_HEADER)
|
||||
endif()
|
||||
#-----------------------------------------------------------------
|
||||
find_path( UNISTD_HEADER unistd.h /usr/include )
|
||||
if (UNISTD_HEADER)
|
||||
add_definitions( -DHAVE_UNISTD )
|
||||
endif()
|
||||
|
||||
if (ERT_WINDOWS)
|
||||
find_library( SHLWAPI_LIBRARY NAMES Shlwapi )
|
||||
|
@ -1,8 +1,8 @@
|
||||
function( ert_module module args source_files )
|
||||
|
||||
set( build_file ${CMAKE_CURRENT_BINARY_DIR}/${module}.so )
|
||||
function( ert_module target args source_files )
|
||||
|
||||
set( build_file ${target}.so )
|
||||
set( depends analysis )
|
||||
set( arg_string "${module} ${args}")
|
||||
set( arg_string "${target} ${args}")
|
||||
separate_arguments( arg_list UNIX_COMMAND "${arg_string}")
|
||||
foreach (src_file ${source_files} )
|
||||
list(APPEND arg_list ${CMAKE_CURRENT_SOURCE_DIR}/${src_file} )
|
||||
@ -16,6 +16,8 @@ function( ert_module module args source_files )
|
||||
DEPENDS ${depends})
|
||||
|
||||
install(FILES ${build_file} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
get_filename_component( module ${target} NAME )
|
||||
add_custom_target( ${module} ALL DEPENDS ${build_file} )
|
||||
|
||||
endfunction()
|
||||
|
@ -22,6 +22,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/matrix.h>
|
||||
|
||||
|
||||
@ -38,11 +39,22 @@ extern "C" {
|
||||
*/
|
||||
|
||||
|
||||
#define ANALYSIS_NEED_ED 1
|
||||
#define ANALYSIS_USE_A 4 // The module will read the content of A - but not modify it.
|
||||
#define ANALYSIS_UPDATE_A 8 // The update will be based on modifying A directly, and not on an X matrix.
|
||||
#define ANALYSIS_SCALE_DATA 16
|
||||
#define ANALYSIS_ITERABLE 32 // The module can bu uused as an iterative smoother.
|
||||
typedef enum {
|
||||
ANALYSIS_NEED_ED = 1,
|
||||
ANALYSIS_USE_A = 4, // The module will read the content of A - but not modify it.
|
||||
ANALYSIS_UPDATE_A = 8, // The update will be based on modifying A directly, and not on an X matrix.
|
||||
ANALYSIS_SCALE_DATA = 16,
|
||||
ANALYSIS_ITERABLE = 32 // The module can bu used as an iterative smoother.
|
||||
} analysis_module_flag_enum;
|
||||
|
||||
|
||||
#define ANALYSIS_MODULE_FLAG_ENUM_SIZE 5
|
||||
#define ANALYSIS_MODULE_FLAG_ENUM_DEFS {.value = ANALYSIS_NEED_ED , .name = "ANALYSIS_NEED_ED"},\
|
||||
{.value = ANALYSIS_USE_A , .name = "ANALYSIS_USE_A"},\
|
||||
{.value = ANALYSIS_UPDATE_A , .name = "ANALYSIS_UPDATE_A"},\
|
||||
{.value = ANALYSIS_SCALE_DATA , .name = "ANALYSIS_SCALE_DATA"},\
|
||||
{.value = ANALYSIS_ITERABLE , .name = "ANALYSIS_ITERABLE"}
|
||||
|
||||
|
||||
#define EXTERNAL_MODULE_NAME "analysis_table"
|
||||
#define EXTERNAL_MODULE_SYMBOL analysis_table
|
||||
@ -96,13 +108,18 @@ extern "C" {
|
||||
bool analysis_module_set_var( analysis_module_type * module , const char * var_name , const char * string_value );
|
||||
const char * analysis_module_get_table_name( const analysis_module_type * module);
|
||||
const char * analysis_module_get_name( const analysis_module_type * module );
|
||||
bool analysis_module_get_option( const analysis_module_type * module , long flag);
|
||||
bool analysis_module_check_option( const analysis_module_type * module , long flag);
|
||||
void analysis_module_complete_update( analysis_module_type * module );
|
||||
|
||||
bool analysis_module_has_var( const analysis_module_type * module , const char * var );
|
||||
double analysis_module_get_double( const analysis_module_type * module , const char * var);
|
||||
int analysis_module_get_int( const analysis_module_type * module , const char * var);
|
||||
void * analysis_module_get_ptr( const analysis_module_type * module , const char * var);
|
||||
const char * analysis_module_flag_enum_iget( int index, int * value);
|
||||
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( analysis_module );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void enkf_linalg_rml_enkfX3(matrix_type *X3, matrix_type *VdTr, double *Wdr,matr
|
||||
void enkf_linalg_rml_enkfdA(matrix_type *dA1,matrix_type *Dm,matrix_type *X3);
|
||||
|
||||
double enkf_linalg_data_mismatch(matrix_type *D , matrix_type *R , matrix_type *Sk);
|
||||
void enkf_linalg_Covariance(matrix_type *Cd, matrix_type *E, double nsc ,int nrobs);
|
||||
void enkf_linalg_Covariance(matrix_type *Cd, const matrix_type *E, double nsc ,int nrobs);
|
||||
void enkf_linalg_rml_enkfAm(matrix_type * Um, double * Wm,int nsign1);
|
||||
|
||||
void enkf_linalg_rml_enkfX4 (matrix_type *X4,matrix_type *Am, matrix_type *A);
|
||||
|
@ -4,4 +4,9 @@ set( RML_SOURCE_FILES
|
||||
rml_enkf.c
|
||||
rml_enkf_common.c )
|
||||
|
||||
ert_module( rml_enkf ${args} "${RML_SOURCE_FILES}")
|
||||
set( RMLI_SOURCE_FILES
|
||||
rml_enkf_imodel.c
|
||||
rml_enkf_common.c )
|
||||
|
||||
ert_module( ${LIBRARY_OUTPUT_PATH}/rml_enkf ${args} "${RML_SOURCE_FILES}")
|
||||
ert_module( ${LIBRARY_OUTPUT_PATH}/rmli_enkf ${args} "${RMLI_SOURCE_FILES}")
|
||||
|
129
ThirdParty/Ert/devel/libanalysis/modules/rml_enkf.c
vendored
129
ThirdParty/Ert/devel/libanalysis/modules/rml_enkf.c
vendored
@ -89,11 +89,10 @@ struct rml_enkf_data_struct {
|
||||
long option_flags;
|
||||
|
||||
int iteration_nr; // Keep track of the outer iteration loop
|
||||
double lamda; // parameter to control the search direction in Marquardt levenberg optimization
|
||||
double lambda; // parameter to control the search direction in Marquardt levenberg optimization
|
||||
double Sk; // Objective function value
|
||||
double Std; // Standard Deviation of the Objective function
|
||||
matrix_type *state;
|
||||
matrix_type *Cd;
|
||||
};
|
||||
|
||||
|
||||
@ -143,7 +142,6 @@ void * rml_enkf_data_alloc( rng_type * rng) {
|
||||
data->option_flags = ANALYSIS_NEED_ED + ANALYSIS_UPDATE_A + ANALYSIS_ITERABLE;
|
||||
data->iteration_nr = 0;
|
||||
data->Std = 0;
|
||||
data->Cd = NULL;
|
||||
data->state = NULL;
|
||||
return data;
|
||||
}
|
||||
@ -152,9 +150,6 @@ void * rml_enkf_data_alloc( rng_type * rng) {
|
||||
void rml_enkf_data_free( void * module_data ) {
|
||||
rml_enkf_data_type * data = rml_enkf_data_safe_cast( module_data );
|
||||
|
||||
if (data->Cd != NULL)
|
||||
matrix_free( data->Cd );
|
||||
|
||||
if (data->state != NULL)
|
||||
matrix_free( data->state );
|
||||
|
||||
@ -165,6 +160,19 @@ void rml_enkf_data_free( void * module_data ) {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
About the matrix Cd: The matrix Cd is calculated based on the content
|
||||
of the E input matrix. In the original implementation this matrix was
|
||||
only calculated in the first iteration, and then reused between subsequent
|
||||
iterations.
|
||||
|
||||
Due to deactivating outliers the number of active observations can change
|
||||
from one iteration to the next, if the matrix Cd is then reused between
|
||||
iterations we will get a matrix size mismatch in the linear algebra. In the
|
||||
current implementation the Cd matrix is recalculated based on the E input
|
||||
for each iteration.
|
||||
*/
|
||||
|
||||
void rml_enkf_updateA(void * module_data ,
|
||||
matrix_type * A ,
|
||||
matrix_type * S ,
|
||||
@ -181,6 +189,7 @@ void rml_enkf_updateA(void * module_data ,
|
||||
|
||||
int ens_size = matrix_get_columns( S );
|
||||
int nrobs = matrix_get_rows( S );
|
||||
matrix_type * Cd = matrix_alloc( nrobs , nrobs);
|
||||
double nsc = 1/sqrt(ens_size-1);
|
||||
matrix_type * Skm = matrix_alloc(matrix_get_columns(D),matrix_get_columns(D));
|
||||
FILE *fp = util_fopen("rml_enkf_output","a");
|
||||
@ -191,82 +200,76 @@ void rml_enkf_updateA(void * module_data ,
|
||||
double * Wd = util_calloc( nrmin , sizeof * Wd );
|
||||
|
||||
|
||||
|
||||
|
||||
Cd = matrix_alloc( nrobs, nrobs );
|
||||
enkf_linalg_Covariance(Cd ,E ,nsc, nrobs);
|
||||
matrix_inv(Cd);
|
||||
|
||||
if (data->iteration_nr == 0) {
|
||||
data->Cd = matrix_alloc( nrobs, nrobs );
|
||||
enkf_linalg_Covariance(data->Cd ,E ,nsc, nrobs);
|
||||
matrix_inv(data->Cd);
|
||||
|
||||
Sk_new = enkf_linalg_data_mismatch(D,data->Cd,Skm); //Calculate the intitial data mismatch term
|
||||
Std_new= matrix_diag_std(Skm,Sk_new);
|
||||
data->lamda =pow(10,floor(log10(Sk_new/(2*nrobs))));
|
||||
Sk_new = enkf_linalg_data_mismatch(D,Cd,Skm); //Calculate the intitial data mismatch term
|
||||
Std_new = matrix_diag_std(Skm,Sk_new);
|
||||
data->lambda = pow(10,floor(log10(Sk_new/(2*nrobs))));
|
||||
data->state = matrix_realloc_copy(data->state , A);
|
||||
rml_enkf_common_initA__(A,S,data->Cd,E,D,truncation,data->lamda,Ud,Wd,VdT);
|
||||
data->Sk = Sk_new;
|
||||
data->Std=Std_new;
|
||||
rml_enkf_common_initA__(A,S,Cd,E,D,truncation,data->lambda,Ud,Wd,VdT);
|
||||
data->Sk = Sk_new;
|
||||
data->Std = Std_new;
|
||||
printf("Prior Objective function value is %5.3f \n", data->Sk);
|
||||
|
||||
fprintf(fp,"Iteration number\t Lamda Value \t Current Mean (OB FN) \t Old Mean\t Current Stddev\n");
|
||||
fprintf(fp, "\n\n");
|
||||
fprintf(fp,"%d \t\t NA \t %5.5f \t \t %5.5f \n",data->iteration_nr, Sk_new, Std_new);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
} else {
|
||||
Sk_new = enkf_linalg_data_mismatch(D , Cd , Skm); //Calculate the intitial data mismatch term
|
||||
Std_new= matrix_diag_std(Skm,Sk_new);
|
||||
printf(" Current Objective function value is %5.3f \n\n",Sk_new);
|
||||
printf("The old Objective function value is %5.3f \n", data->Sk);
|
||||
|
||||
|
||||
if ((Sk_new< (data->Sk)) && (Std_new< (data->Std)))
|
||||
{
|
||||
Sk_new = enkf_linalg_data_mismatch(D,data->Cd,Skm); //Calculate the intitial data mismatch term
|
||||
Std_new= matrix_diag_std(Skm,Sk_new);
|
||||
printf(" Current Objective function value is %5.3f \n\n",Sk_new);
|
||||
printf("The old Objective function value is %5.3f \n", data->Sk);
|
||||
|
||||
|
||||
if ((Sk_new< (data->Sk)) && (Std_new< (data->Std)))
|
||||
{
|
||||
if ( (1- (Sk_new/data->Sk)) < .0001) // check convergence ** model change norm has to be added in this!!
|
||||
data-> iteration_nr = 16;
|
||||
if ( (1- (Sk_new/data->Sk)) < .0001) // check convergence ** model change norm has to be added in this!!
|
||||
data-> iteration_nr = 16;
|
||||
|
||||
|
||||
fprintf(fp,"%d \t\t %5.5f \t %5.5f \t %5.5f \t %5.5f \n",data->iteration_nr,data->lamda, Sk_new,data->Sk, Std_new);
|
||||
data->lamda = data->lamda / 10 ;
|
||||
data->Std = Std_new;
|
||||
data->state = matrix_realloc_copy(data->state , A);
|
||||
data->Sk = Sk_new;
|
||||
rml_enkf_common_initA__(A,S,data->Cd,E,D,truncation,data->lamda,Ud,Wd,VdT);
|
||||
fprintf(fp,"%d \t\t %5.5f \t %5.5f \t %5.5f \t %5.5f \n",data->iteration_nr,data->lambda, Sk_new,data->Sk, Std_new);
|
||||
data->lambda = data->lambda / 10 ;
|
||||
data->Std = Std_new;
|
||||
data->state = matrix_realloc_copy(data->state , A);
|
||||
data->Sk = Sk_new;
|
||||
rml_enkf_common_initA__(A,S,Cd,E,D,truncation,data->lambda,Ud,Wd,VdT);
|
||||
}
|
||||
else if((Sk_new< (data->Sk)) && (Std_new > (data->Std)))
|
||||
{
|
||||
if ( (1- (Sk_new/data->Sk)) < .0001) // check convergence ** model change norm has to be added in this!!
|
||||
data-> iteration_nr = 16;
|
||||
|
||||
|
||||
fprintf(fp,"%d \t\t %5.5f \t %5.5f \t %5.5f \t %5.5f \n",data->iteration_nr,data->lambda, Sk_new,data->Sk, Std_new);
|
||||
data->Std=Std_new;
|
||||
data->state = matrix_realloc_copy(data->state , A);
|
||||
data->Sk = Sk_new;
|
||||
rml_enkf_common_initA__(A,S,Cd,E,D,truncation,data->lambda,Ud,Wd,VdT);
|
||||
}
|
||||
else {
|
||||
fprintf(fp,"%d \t\t %5.5f \t %5.5f \t %5.5f \t %5.5f \n",data->iteration_nr,data->lambda, Sk_new,data->Sk, Std_new);
|
||||
printf("The previous step is rejected !!\n");
|
||||
data->lambda = data ->lambda * 4;
|
||||
matrix_assign( A , data->state );
|
||||
rml_enkf_common_initA__(A,S,Cd,E,D,truncation,data->lambda,Ud,Wd,VdT);
|
||||
data->iteration_nr--;
|
||||
}
|
||||
else if((Sk_new< (data->Sk)) && (Std_new > (data->Std)))
|
||||
{
|
||||
if ( (1- (Sk_new/data->Sk)) < .0001) // check convergence ** model change norm has to be added in this!!
|
||||
data-> iteration_nr = 16;
|
||||
|
||||
|
||||
fprintf(fp,"%d \t\t %5.5f \t %5.5f \t %5.5f \t %5.5f \n",data->iteration_nr,data->lamda, Sk_new,data->Sk, Std_new);
|
||||
data->lamda = data->lamda; // Here we are not updating lamda!
|
||||
data->Std=Std_new;
|
||||
data->state = matrix_realloc_copy(data->state , A);
|
||||
data->Sk = Sk_new;
|
||||
rml_enkf_common_initA__(A,S,data->Cd,E,D,truncation,data->lamda,Ud,Wd,VdT);
|
||||
}
|
||||
else {
|
||||
fprintf(fp,"%d \t\t %5.5f \t %5.5f \t %5.5f \t %5.5f \n",data->iteration_nr,data->lamda, Sk_new,data->Sk, Std_new);
|
||||
printf("The previous step is rejected !!\n");
|
||||
data->lamda = data ->lamda * 4;
|
||||
matrix_assign( A , data->state );
|
||||
rml_enkf_common_initA__(A,S,data->Cd,E,D,truncation,data->lamda,Ud,Wd,VdT);
|
||||
data->iteration_nr--;
|
||||
}
|
||||
}
|
||||
data->iteration_nr++;
|
||||
|
||||
//setting the lower bound for lamda
|
||||
if (data->lamda <.01)
|
||||
data->lamda= .01;
|
||||
|
||||
// setting the lower bound for lambda
|
||||
if (data->lambda <.01)
|
||||
data->lambda= .01;
|
||||
|
||||
|
||||
printf ("The current iteration number is %d \n ", data->iteration_nr);
|
||||
|
||||
|
||||
|
||||
matrix_free(Cd);
|
||||
matrix_free(Ud);
|
||||
matrix_free(VdT);
|
||||
matrix_free(Skm);
|
||||
|
@ -32,9 +32,10 @@
|
||||
#include <ert/analysis/analysis_module.h>
|
||||
#include <ert/analysis/analysis_table.h>
|
||||
#include <ert/analysis/enkf_linalg.h>
|
||||
#include <ert/analysis/rml_enkf_common.h>
|
||||
#include <ert/analysis/std_enkf.h>
|
||||
|
||||
#include <rml_enkf_common.h>
|
||||
|
||||
/*
|
||||
A random 'magic' integer id which is used for run-time type checking
|
||||
of the input data.
|
||||
@ -139,7 +140,7 @@ void * rml_enkf_imodel_data_alloc( rng_type * rng) {
|
||||
|
||||
rml_enkf_imodel_set_truncation( data , DEFAULT_ENKF_TRUNCATION_ );
|
||||
rml_enkf_imodel_set_subspace_dimension( data , DEFAULT_SUBSPACE_DIMENSION );
|
||||
data->option_flags = ANALYSIS_NEED_ED + ANALYSIS_UPDATE_A;
|
||||
data->option_flags = ANALYSIS_NEED_ED + ANALYSIS_UPDATE_A + ANALYSIS_ITERABLE;
|
||||
data->iteration_nr = 0;
|
||||
data->Std = 0;
|
||||
return data;
|
||||
@ -473,7 +474,6 @@ long rml_enkf_imodel_get_options( void * arg , long flag ) {
|
||||
|
||||
|
||||
bool rml_enkf_imodel_has_var( const void * arg, const char * var_name) {
|
||||
const rml_enkf_imodel_data_type * module_data = rml_enkf_imodel_data_safe_cast_const( arg );
|
||||
{
|
||||
if (strcmp(var_name , "ITER") == 0)
|
||||
return true;
|
@ -4,7 +4,7 @@ import os
|
||||
import os.path
|
||||
from optparse import OptionParser
|
||||
|
||||
ert_root = os.path.realpath( os.path.join(os.path.dirname( os.path.abspath( __file__)) , "../") )
|
||||
ert_root = os.path.realpath( os.path.join(os.path.dirname( os.path.realpath( os.path.abspath( __file__))) , "../") )
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
|
@ -6,25 +6,13 @@ set_target_properties( analysis PROPERTIES COMPILE_DEFINITIONS INTERNAL_LINK)
|
||||
set_target_properties( analysis PROPERTIES VERSION 1.0 SOVERSION 1.0 )
|
||||
|
||||
target_link_libraries( analysis ert_util )
|
||||
if (NEED_LIBDL)
|
||||
target_link_libraries( analysis dl )
|
||||
endif()
|
||||
target_link_libraries( analysis dl )
|
||||
|
||||
if (USE_RUNPATH)
|
||||
add_runpath( analysis )
|
||||
endif()
|
||||
|
||||
|
||||
## List of modules
|
||||
#set( CMAKE_SHARED_MODULE_PREFIX "" )
|
||||
##add_library( std_enkf MODULE std_enkf.c )
|
||||
#add_library( sqrt_enkf MODULE sqrt_enkf.c )
|
||||
#add_library( rml_enkf MODULE rml_enkf.c rml_enkf_common.c )
|
||||
#
|
||||
#ert_module( std_enkf std_enkf.c )
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
if (INSTALL_ERT)
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <ert/util/matrix.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/rng.h>
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/analysis/analysis_module.h>
|
||||
#include <ert/analysis/analysis_table.h>
|
||||
@ -81,9 +82,12 @@ static analysis_module_type * analysis_module_alloc_empty( const char * user_nam
|
||||
module->get_int = NULL;
|
||||
module->get_double = NULL;
|
||||
module->get_ptr = NULL;
|
||||
module->user_name = util_alloc_string_copy( user_name );
|
||||
module->symbol_table = util_alloc_string_copy( symbol_table );
|
||||
module->lib_name = util_alloc_string_copy( lib_name );
|
||||
module->alloc = NULL;
|
||||
|
||||
module->user_name = util_alloc_string_copy( user_name );
|
||||
module->symbol_table = util_alloc_string_copy( symbol_table );
|
||||
module->lib_name = util_alloc_string_copy( lib_name );
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
@ -119,7 +123,7 @@ static analysis_module_type * analysis_module_alloc__( rng_type * rng ,
|
||||
module->get_double = table->get_double;
|
||||
module->get_ptr = table->get_ptr;
|
||||
|
||||
if (module->alloc != NULL)
|
||||
if (module->alloc)
|
||||
module->module_data = module->alloc( rng );
|
||||
|
||||
if (!analysis_module_internal_check( module )) {
|
||||
@ -213,6 +217,7 @@ bool analysis_module_internal( const analysis_module_type * module ) {
|
||||
/*****************************************************************/
|
||||
|
||||
static UTIL_SAFE_CAST_FUNCTION( analysis_module , ANALYSIS_MODULE_TYPE_ID )
|
||||
UTIL_IS_INSTANCE_FUNCTION( analysis_module , ANALYSIS_MODULE_TYPE_ID )
|
||||
|
||||
|
||||
void analysis_module_free( analysis_module_type * module ) {
|
||||
@ -372,13 +377,16 @@ bool analysis_module_set_var( analysis_module_type * module , const char * var_n
|
||||
}
|
||||
|
||||
|
||||
bool analysis_module_get_option( const analysis_module_type * module , long flag) {
|
||||
return (flag & module->get_options( module->module_data , flag ));
|
||||
bool analysis_module_check_option( const analysis_module_type * module , long flag) {
|
||||
if ((flag & module->get_options( module->module_data , flag )) == flag)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool analysis_module_has_var( const analysis_module_type * module , const char * var) {
|
||||
if (module->has_var != NULL)
|
||||
if (module->has_var)
|
||||
return module->has_var( module->module_data , var );
|
||||
else
|
||||
return false;
|
||||
@ -422,3 +430,11 @@ void * analysis_module_get_ptr( const analysis_module_type * module , const char
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
const char * analysis_module_flag_enum_iget( int index, int * value) {
|
||||
return util_enum_iget( index , ANALYSIS_MODULE_FLAG_ENUM_SIZE , (const util_enum_element_type []) { ANALYSIS_MODULE_FLAG_ENUM_DEFS }, value);
|
||||
}
|
||||
|
||||
|
@ -180,8 +180,6 @@ int enkf_linalg_svdS(const matrix_type * S ,
|
||||
}
|
||||
}
|
||||
|
||||
printf("PCA completed: Number of significant terms = %d\n",num_significant);
|
||||
|
||||
/* Inverting the significant singular values */
|
||||
for (i = 0; i < num_significant; i++)
|
||||
inv_sig0[i] = 1.0 / sig0[i];
|
||||
@ -700,9 +698,15 @@ double enkf_linalg_data_mismatch(matrix_type *D , matrix_type *R , matrix_type *
|
||||
{
|
||||
matrix_type * tmp = matrix_alloc (matrix_get_columns(D), matrix_get_columns(R));
|
||||
double mean;
|
||||
|
||||
|
||||
printf("-----------------------------------------------------------------\n");
|
||||
printf("%s:%d Calling matrix_dgemm() \n",__func__ , __LINE__);
|
||||
// C A B
|
||||
matrix_dgemm(tmp, D, R,true, false, 1.0, 0.0);
|
||||
printf("-----------------------------------------------------------------\n");
|
||||
printf("%s:%d Calling matrix_dgemm() \n",__func__ , __LINE__);
|
||||
matrix_dgemm(Sk, tmp, D, false, false, 1.0, 0.0);
|
||||
printf("-----------------------------------------------------------------\n");
|
||||
|
||||
printf("The data mismatch computed");
|
||||
|
||||
@ -712,7 +716,7 @@ double enkf_linalg_data_mismatch(matrix_type *D , matrix_type *R , matrix_type *
|
||||
return mean;
|
||||
}
|
||||
|
||||
void enkf_linalg_Covariance(matrix_type *Cd, matrix_type *E, double nsc ,int nrobs)
|
||||
void enkf_linalg_Covariance(matrix_type *Cd, const matrix_type *E, double nsc ,int nrobs)
|
||||
{
|
||||
matrix_matlab_dump( E, "matrixE.dat");
|
||||
printf("Starting Dgemm for EE(T)\n");
|
||||
|
@ -1 +1,9 @@
|
||||
add_test( analysis_rml_enkf_module ${EXECUTABLE_OUTPUT_PATH}/ert_module_test ${PROJECT_BINARY_DIR}/libanalysis/modules/rml_enkf.so )
|
||||
add_test( analysis_module_test_RML ${EXECUTABLE_OUTPUT_PATH}/ert_module_test ${LIBRARY_OUTPUT_PATH}/rml_enkf.so )
|
||||
add_test( analysis_module_test_RMLI ${EXECUTABLE_OUTPUT_PATH}/ert_module_test ${LIBRARY_OUTPUT_PATH}/rmli_enkf.so )
|
||||
|
||||
|
||||
add_executable(analysis_test_external_module analysis_test_external_module.c )
|
||||
target_link_libraries( analysis_test_external_module analysis util test_util )
|
||||
|
||||
add_test( analysis_module_rml ${EXECUTABLE_OUTPUT_PATH}/analysis_test_external_module "RML_ENKF" ${LIBRARY_OUTPUT_PATH}/rml_enkf.so 41 ITER)
|
||||
add_test( analysis_module_rmli ${EXECUTABLE_OUTPUT_PATH}/analysis_test_external_module "RMLI_ENKF" ${LIBRARY_OUTPUT_PATH}/rmli_enkf.so 41 ITER)
|
62
ThirdParty/Ert/devel/libanalysis/tests/analysis_test_external_module.c
vendored
Normal file
62
ThirdParty/Ert/devel/libanalysis/tests/analysis_test_external_module.c
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'analysis_test_external_module.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT 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.
|
||||
|
||||
ERT 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 <stdlib.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/rng.h>
|
||||
|
||||
#include <ert/analysis/analysis_module.h>
|
||||
|
||||
|
||||
|
||||
void load_module( rng_type * rng , const char * user_name , const char * lib_name, const char * options_str , int nvar , const char ** var_list) {
|
||||
long flags = strtol(options_str , NULL , 10);
|
||||
analysis_module_type * analysis_module = analysis_module_alloc_external(rng , user_name , lib_name);
|
||||
|
||||
printf("Loading:%s \n" , lib_name);
|
||||
test_assert_string_equal( EXTERNAL_MODULE_NAME , analysis_module_get_table_name(analysis_module));
|
||||
if (util_is_abs_path(lib_name))
|
||||
test_assert_string_equal( lib_name , analysis_module_get_lib_name(analysis_module));
|
||||
|
||||
test_assert_true( analysis_module_is_instance( analysis_module));
|
||||
for (int i=0; i < nvar; i++) {
|
||||
printf("has_var(%s) \n" , var_list[i]);
|
||||
test_assert_true( analysis_module_has_var(analysis_module , var_list[i]));
|
||||
}
|
||||
test_assert_false( analysis_module_has_var(analysis_module , "DoesNotHaveThisVariable"));
|
||||
test_assert_true( analysis_module_check_option( analysis_module , flags));
|
||||
flags += 1;
|
||||
test_assert_false( analysis_module_check_option( analysis_module , flags));
|
||||
analysis_module_free( analysis_module);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * user_name = argv[1];
|
||||
const char * lib_name = argv[2];
|
||||
const char * options_str = argv[3];
|
||||
int nvar = argc - 4;
|
||||
rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT);
|
||||
|
||||
load_module(rng , user_name , lib_name , options_str , nvar , (const char **) &argv[4]);
|
||||
rng_free( rng );
|
||||
|
||||
exit(0);
|
||||
}
|
2
ThirdParty/Ert/devel/libconfig/src/config.c
vendored
2
ThirdParty/Ert/devel/libconfig/src/config.c
vendored
@ -648,7 +648,7 @@ static void config_parse__(config_type * config ,
|
||||
current_path_elm = config_add_path_elm( config , config_path );
|
||||
path_stack_push_cwd( path_stack );
|
||||
if (config_path != NULL) {
|
||||
chdir( config_path );
|
||||
util_chdir( config_path );
|
||||
free( config_path );
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ void parse_test(config_type * config ,
|
||||
util_alloc_file_components( config_file , &config_path , NULL , NULL);
|
||||
path_stack_push( path_stack , NULL );
|
||||
if (root_path != NULL)
|
||||
chdir( root_path );
|
||||
util_chdir( root_path );
|
||||
|
||||
config_abs_path = util_alloc_abs_path( config_path );
|
||||
config_rel_path = util_alloc_rel_path( NULL , config_abs_path);
|
||||
|
@ -36,13 +36,13 @@ int main(int argc , char ** argv) {
|
||||
|
||||
|
||||
#endif
|
||||
test_work_area_type * work_area = test_work_area_alloc( "config_path_elm" , true );
|
||||
test_work_area_type * work_area = test_work_area_alloc( "config_path_elm" );
|
||||
const char * root = test_work_area_get_cwd( work_area );
|
||||
char * abs_path = util_alloc_filename( root , "rel/path" , NULL);
|
||||
char * abs_true = util_alloc_filename( root , "rel/path/XXX" , NULL);
|
||||
char * path_true2 = util_alloc_filename( root , "rel/path/XXX" , NULL);
|
||||
|
||||
chdir( test_work_area_get_original_cwd( work_area ));
|
||||
util_chdir( test_work_area_get_original_cwd( work_area ));
|
||||
config_root_path_type * root_path = config_root_path_alloc( root );
|
||||
{
|
||||
config_path_elm_type * path_elm = config_path_elm_alloc( root_path , rel_path );
|
||||
@ -71,7 +71,7 @@ int main(int argc , char ** argv) {
|
||||
}
|
||||
config_root_path_free( root_path );
|
||||
|
||||
chdir( root );
|
||||
util_chdir( root );
|
||||
root_path = config_root_path_alloc( NULL );
|
||||
{
|
||||
config_path_elm_type * path_elm = config_path_elm_alloc( root_path , rel_path );
|
||||
|
@ -832,7 +832,7 @@ int main( int argc , char ** argv ) {
|
||||
char * config_path;
|
||||
util_alloc_file_components( config_arg , &config_path , NULL , NULL);
|
||||
if (config_path != NULL) {
|
||||
chdir( config_path );
|
||||
util_chdir( config_path );
|
||||
free( config_path );
|
||||
}
|
||||
} else {
|
||||
|
@ -173,6 +173,8 @@ bool ecl_util_fmt_file(const char * filename , bool * __fmt_file);
|
||||
char * ecl_util_alloc_exfilename_anyfmt(const char * path, const char * base , ecl_file_enum file_type , bool start_fmt , int report_nr);
|
||||
int ecl_util_get_month_nr(const char * month_name);
|
||||
int ecl_util_fname_report_cmp(const void *f1, const void *f2);
|
||||
time_t ecl_util_make_date(int mday , int month , int year);
|
||||
time_t ecl_util_make_date__(int mday , int month , int year, int * year_offset);
|
||||
|
||||
bool ecl_util_valid_basename( const char * basename );
|
||||
const char * ecl_util_get_phase_name( ecl_phase_enum phase );
|
||||
|
15
ThirdParty/Ert/devel/libecl/src/CMakeLists.txt
vendored
15
ThirdParty/Ert/devel/libecl/src/CMakeLists.txt
vendored
@ -13,21 +13,6 @@ set_target_properties( ecl PROPERTIES VERSION 1.0 SOVERSION 1.0 )
|
||||
if (USE_RUNPATH)
|
||||
add_runpath( ecl )
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
set( OPENMP OFF )
|
||||
option(USE_OPENMP "Include OpenMP support" OFF)
|
||||
if (USE_OPENMP)
|
||||
INCLUDE(CheckCCompilerFlag)
|
||||
CHECK_C_COMPILER_FLAG(-fopenmp OPENMP)
|
||||
endif()
|
||||
|
||||
if (OPENMP)
|
||||
add_definitions( -DHAVE_OPENMP -fopenmp )
|
||||
target_link_libraries( ecl gomp )
|
||||
else()
|
||||
add_definitions( -fno-openmp )
|
||||
endif()
|
||||
target_link_libraries( ecl ert_geometry ert_util )
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
7
ThirdParty/Ert/devel/libecl/src/ecl_grid.c
vendored
7
ThirdParty/Ert/devel/libecl/src/ecl_grid.c
vendored
@ -42,13 +42,6 @@
|
||||
#include <ert/ecl/nnc_info.h>
|
||||
#include <ert/ecl/nnc_index_list.h>
|
||||
|
||||
/*
|
||||
If openmp is enabled the main loop in ecl_grid_init_GRDECL_data is
|
||||
parallelized with openmp.
|
||||
*/
|
||||
#ifdef HAVE_OPENMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
this function implements functionality to load eclispe grid files,
|
||||
|
@ -225,7 +225,7 @@ ecl_rft_node_type * ecl_rft_node_alloc(const ecl_file_type * rft) {
|
||||
/* Time information. */
|
||||
{
|
||||
int * time = ecl_kw_get_int_ptr( date_kw );
|
||||
rft_node->recording_date = util_make_date( time[DATE_DAY_INDEX] , time[DATE_MONTH_INDEX] , time[DATE_YEAR_INDEX] );
|
||||
rft_node->recording_date = ecl_util_make_date( time[DATE_DAY_INDEX] , time[DATE_MONTH_INDEX] , time[DATE_YEAR_INDEX] );
|
||||
}
|
||||
rft_node->days = ecl_kw_iget_float( ecl_file_iget_named_kw( rft , TIME_KW , 0 ) , 0);
|
||||
if (ecl_file_has_kw( rft , CONLENST_KW))
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
|
||||
static time_t rsthead_date( int day , int month , int year) {
|
||||
return util_make_date( day , month, year );
|
||||
return ecl_util_make_date( day , month, year );
|
||||
}
|
||||
|
||||
|
||||
|
6
ThirdParty/Ert/devel/libecl/src/ecl_smspec.c
vendored
6
ThirdParty/Ert/devel/libecl/src/ecl_smspec.c
vendored
@ -1058,9 +1058,9 @@ static void ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h
|
||||
|
||||
{
|
||||
int * date = ecl_kw_get_int_ptr(startdat);
|
||||
ecl_smspec->sim_start_time = util_make_date(date[STARTDAT_DAY_INDEX] ,
|
||||
date[STARTDAT_MONTH_INDEX] ,
|
||||
date[STARTDAT_YEAR_INDEX]);
|
||||
ecl_smspec->sim_start_time = ecl_util_make_date(date[STARTDAT_DAY_INDEX] ,
|
||||
date[STARTDAT_MONTH_INDEX] ,
|
||||
date[STARTDAT_YEAR_INDEX]);
|
||||
}
|
||||
|
||||
ecl_smspec->grid_dims[0] = ecl_kw_iget_int(dimens , DIMENS_SMSPEC_NX_INDEX );
|
||||
|
36
ThirdParty/Ert/devel/libecl/src/ecl_util.c
vendored
36
ThirdParty/Ert/devel/libecl/src/ecl_util.c
vendored
@ -1235,7 +1235,7 @@ time_t ecl_util_get_start_date(const char * data_file) {
|
||||
int day, year, month_nr;
|
||||
if ( util_sscanf_int( stringlist_iget( tokens , 0 ) , &day) && util_sscanf_int( stringlist_iget(tokens , 2) , &year)) {
|
||||
month_nr = ecl_util_get_month_nr(stringlist_iget( tokens , 1));
|
||||
start_date = util_make_date(day , month_nr , year );
|
||||
start_date = ecl_util_make_date(day , month_nr , year );
|
||||
} else
|
||||
util_abort("%s: failed to parse DAY MONTH YEAR from : \"%s\" \n",__func__ , buffer);
|
||||
stringlist_free( tokens );
|
||||
@ -1364,7 +1364,7 @@ void ecl_util_append_month_range( time_t_vector_type * date_list , time_t start_
|
||||
} else
|
||||
month += 1;
|
||||
|
||||
current_date = util_make_date( 1 , month , year );
|
||||
current_date = ecl_util_make_date( 1 , month , year );
|
||||
if (current_date < end_date)
|
||||
time_t_vector_append( date_list , current_date );
|
||||
else {
|
||||
@ -1389,6 +1389,38 @@ void ecl_util_init_month_range( time_t_vector_type * date_list , time_t start_da
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
time_t ecl_util_make_date__(int mday , int month , int year, int * __year_offset) {
|
||||
time_t date;
|
||||
|
||||
#ifdef TIME_T_64BIT_ACCEPT_PRE1970
|
||||
*__year_offset = 0;
|
||||
date = util_make_date(mday , month , year);
|
||||
#else
|
||||
static bool offset_initialized = false;
|
||||
static int year_offset = 0;
|
||||
|
||||
if (!offset_initialized) {
|
||||
if (year < 1970) {
|
||||
year_offset = 2000 - year;
|
||||
fprintf(stderr,"Warning: all year values will be shifted %d years forward. \n", year_offset);
|
||||
}
|
||||
offset_initialized = true;
|
||||
}
|
||||
*__year_offset = year_offset;
|
||||
date = util_make_date(mday , month , year + year_offset);
|
||||
#endif
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
time_t ecl_util_make_date(int mday , int month , int year) {
|
||||
int year_offset;
|
||||
return ecl_util_make_date__( mday , month , year , &year_offset);
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
/* Small functions to support enum introspection. */
|
||||
|
||||
|
4
ThirdParty/Ert/devel/libecl/tests/ecl_file.c
vendored
4
ThirdParty/Ert/devel/libecl/tests/ecl_file.c
vendored
@ -104,7 +104,7 @@ void test_close_stream1(const char * src_file , const char * target_file ) {
|
||||
|
||||
|
||||
void test_writable(const char * src_file ) {
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_file_writable" , true);
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_file_writable" );
|
||||
char * fname = util_split_alloc_filename( src_file );
|
||||
|
||||
test_work_area_copy_file( work_area , src_file );
|
||||
@ -131,7 +131,7 @@ int main( int argc , char ** argv) {
|
||||
const char * target_file = argv[2];
|
||||
|
||||
{
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_file" , true);
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_file");
|
||||
|
||||
test_work_area_install_file( work_area , src_file );
|
||||
test_flags( src_file );
|
||||
|
2
ThirdParty/Ert/devel/libecl/tests/ecl_fmt.c
vendored
2
ThirdParty/Ert/devel/libecl/tests/ecl_fmt.c
vendored
@ -56,7 +56,7 @@ void test_small( ) {
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_work_area_type * work_area = test_work_area_alloc( "ecl_fmt" , true);
|
||||
test_work_area_type * work_area = test_work_area_alloc( "ecl_fmt");
|
||||
{
|
||||
const char * binary_file = argv[1];
|
||||
const char * text_file = argv[2];
|
||||
|
@ -84,7 +84,7 @@ int main( int argc , char ** argv) {
|
||||
test_wrapper( file );
|
||||
test_write( "/tmp/path/does/not/exist" , false );
|
||||
{
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_fortio.write" , true );
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_fortio.write" );
|
||||
util_make_path("path");
|
||||
test_write( "path/file.x" , true );
|
||||
test_work_area_free( work_area );
|
||||
|
@ -32,7 +32,7 @@ int main(int argc , char ** argv) {
|
||||
ecl_kw_iset_int(ecl_kw , i , i );
|
||||
|
||||
{
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_kw_grdecl" , true);
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_kw_grdecl");
|
||||
FILE * stream = util_fopen( "FILE.grdecl" , "w");
|
||||
|
||||
ecl_kw_fprintf_grdecl(ecl_kw , stream );
|
||||
|
@ -30,5 +30,6 @@
|
||||
|
||||
int main( int argc , char ** argv) {
|
||||
ecl_grid_type * ecl_grid = ecl_grid_alloc( argv[1] );
|
||||
ecl_grid_free( ecl_grid );
|
||||
exit(0);
|
||||
}
|
||||
|
@ -38,18 +38,18 @@ int main(int argc , char ** argv) {
|
||||
nnc_info_add_nnc(nnc_info, 1, 110);
|
||||
nnc_info_add_nnc(nnc_info, 1, 111);
|
||||
|
||||
const nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , 1);
|
||||
nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , 1);
|
||||
const int_vector_type * nnc_cells = nnc_info_get_index_list(nnc_info, 1);
|
||||
test_assert_int_equal(int_vector_size(nnc_cells), 2);
|
||||
test_assert_ptr_equal( nnc_cells , nnc_vector_get_index_list( nnc_vector ));
|
||||
|
||||
|
||||
const nnc_vector_type * nnc_vector_null = nnc_info_get_vector( nnc_info , 2);
|
||||
nnc_vector_type * nnc_vector_null = nnc_info_get_vector( nnc_info , 2);
|
||||
const int_vector_type * nnc_cells_null = nnc_info_get_index_list(nnc_info, 2);
|
||||
test_assert_NULL(nnc_cells_null);
|
||||
test_assert_NULL(nnc_vector_null);
|
||||
|
||||
const nnc_vector_type * nnc_vector_self = nnc_info_get_self_vector( nnc_info );
|
||||
nnc_vector_type * nnc_vector_self = nnc_info_get_self_vector( nnc_info );
|
||||
const nnc_vector_type * nnc_vector_77 = nnc_info_get_vector( nnc_info , lgr_nr );
|
||||
test_assert_ptr_equal( nnc_vector_77 , nnc_vector_self );
|
||||
|
||||
|
48
ThirdParty/Ert/devel/libecl/tests/ecl_util_make_date_no_shift.c
vendored
Normal file
48
ThirdParty/Ert/devel/libecl/tests/ecl_util_make_date_no_shift.c
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_util_make_date_no_shift.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT 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.
|
||||
|
||||
ERT 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 <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/time_t_vector.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
|
||||
void test_date(int mday, int month , int year) {
|
||||
time_t t0 = ecl_util_make_date( mday , month , year );
|
||||
time_t t1 = util_make_date( mday , month , year);
|
||||
|
||||
test_assert_time_t_equal( t0 , t1 );
|
||||
}
|
||||
|
||||
void test_offset(int mday, int month , int year) {
|
||||
int year_offset;
|
||||
ecl_util_make_date__( mday , month , year , &year_offset);
|
||||
test_assert_int_equal( 0 , year_offset );
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_date(10,10,2000);
|
||||
test_offset(10,10,2000);
|
||||
// test_assert_util_abort( make_date( 1 , 1 , 0);
|
||||
exit(0);
|
||||
}
|
51
ThirdParty/Ert/devel/libecl/tests/ecl_util_make_date_shift.c
vendored
Normal file
51
ThirdParty/Ert/devel/libecl/tests/ecl_util_make_date_shift.c
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
/* Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_util_make_date_shift.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT 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.
|
||||
|
||||
ERT 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 <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/time_t_vector.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
|
||||
void test_date(int mday, int month , int year, int * year_offset) {
|
||||
time_t t0 = ecl_util_make_date__( mday , month , year , year_offset);
|
||||
time_t t1 = util_make_date( mday , month , year + *year_offset);
|
||||
test_assert_time_t_equal( t0 , t1 );
|
||||
}
|
||||
|
||||
|
||||
void test_offset(int mday, int month , int year , int current_offset) {
|
||||
int year_offset;
|
||||
time_t t0 = ecl_util_make_date__( mday , month , year , &year_offset);
|
||||
time_t t1 = util_make_date( mday , month , year + current_offset);
|
||||
|
||||
test_assert_time_t_equal(t0,t1);
|
||||
test_assert_int_equal( current_offset , year_offset );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
int year_offset;
|
||||
test_date(1,1,0 , &year_offset);
|
||||
test_offset(1,1,1000 , year_offset);
|
||||
exit(0);
|
||||
}
|
@ -10,6 +10,13 @@ add_executable( ecl_restart_test ecl_restart_test.c )
|
||||
target_link_libraries( ecl_restart_test ecl test_util )
|
||||
add_test( ecl_restart_test ${EXECUTABLE_OUTPUT_PATH}/ecl_restart_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST )
|
||||
|
||||
add_executable( ecl_util_make_date_no_shift ecl_util_make_date_no_shift.c )
|
||||
target_link_libraries( ecl_util_make_date_no_shift ecl test_util )
|
||||
add_test( ecl_util_make_date_no_shift ${EXECUTABLE_OUTPUT_PATH}/ecl_util_make_date_no_shift )
|
||||
|
||||
add_executable( ecl_util_make_date_shift ecl_util_make_date_shift.c )
|
||||
target_link_libraries( ecl_util_make_date_shift ecl test_util )
|
||||
add_test( ecl_util_make_date_shift ${EXECUTABLE_OUTPUT_PATH}/ecl_util_make_date_shift )
|
||||
|
||||
add_executable( ecl_grid_lgr_name ecl_grid_lgr_name.c )
|
||||
target_link_libraries( ecl_grid_lgr_name ecl test_util )
|
||||
|
@ -61,7 +61,7 @@ extern "C" {
|
||||
int well_conn_get_k(const well_conn_type * conn);
|
||||
well_conn_dir_enum well_conn_get_dir(const well_conn_type * conn);
|
||||
bool well_conn_open( const well_conn_type * conn );
|
||||
int well_conn_get_segment( const well_conn_type * conn );
|
||||
int well_conn_get_segment_id( const well_conn_type * conn );
|
||||
bool well_conn_fracture_connection( const well_conn_type * conn);
|
||||
bool well_conn_matrix_connection( const well_conn_type * conn);
|
||||
bool well_conn_equal( const well_conn_type *conn1 , const well_conn_type * conn2);
|
||||
|
@ -24,6 +24,25 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WELL_SEGMENT_OFFSET 1
|
||||
#define WELL_BRANCH_OFFSET 1
|
||||
|
||||
#define ECLIPSE_WELL_SEGMENT_OFFSET 1
|
||||
#define ECLIPSE_WELL_BRANCH_OFFSET 1
|
||||
|
||||
/* These values are taken from the ISEG description in table 6.1 in ECLIPSE file formats reference. */
|
||||
#define ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE 0
|
||||
#define ECLIPSE_WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE 1
|
||||
#define ECLIPSE_WELL_SEGMENT_INACTIVE_VALUE 0
|
||||
#define ECLIPSE_CONN_NORMAL_WELL_SEGMENT_VALUE 0
|
||||
|
||||
#define WELL_SEGMENT_OUTLET_END_VALUE (WELL_SEGMENT_OFFSET + ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE - ECLIPSE_WELL_SEGMENT_OFFSET) // -1
|
||||
#define WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE (WELL_BRANCH_OFFSET + ECLIPSE_WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE - ECLIPSE_WELL_BRANCH_OFFSET) // 0
|
||||
#define WELL_SEGMENT_BRANCH_INACTIVE_VALUE (WELL_BRANCH_OFFSET + ECLIPSE_WELL_SEGMENT_INACTIVE_VALUE - ECLIPSE_WELL_BRANCH_OFFSET) // -1
|
||||
#define CONN_NORMAL_WELL_SEGMENT_VALUE (WELL_SEGMENT_OFFSET + ECLIPSE_CONN_NORMAL_WELL_SEGMENT_VALUE - ECLIPSE_WELL_SEGMENT_OFFSET)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Observe that the values given as _ITEM are not indices which can
|
||||
be directly used in the IWEL or ICON keywords; an offset must be
|
||||
|
@ -33,17 +33,12 @@ extern "C" {
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
|
||||
/* The values are shifted one down compared to ISEG description in table 6.1 in ECLIPSE file formats reference. */
|
||||
|
||||
#define ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE -1
|
||||
#define ECLIPSE_WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE 0
|
||||
#define ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE -1
|
||||
|
||||
|
||||
|
||||
typedef struct well_segment_struct well_segment_type;
|
||||
|
||||
well_segment_type * well_segment_alloc_from_kw( const ecl_kw_type * iseg_kw , const ecl_kw_type * rseg_kw , const ecl_rsthead_type * header , int well_nr, int segment_id);
|
||||
well_segment_type * well_segment_alloc_from_kw( const ecl_kw_type * iseg_kw , const ecl_kw_type * rseg_kw , const ecl_rsthead_type * header , int well_nr, int segment_index , int segment_id);
|
||||
well_segment_type * well_segment_alloc(int segment_id , int outlet_segment_id , int branch_id , const double * rseg_data);
|
||||
void well_segment_free(well_segment_type * segment );
|
||||
void well_segment_free__(void * arg);
|
||||
|
@ -53,7 +53,7 @@ extern "C" {
|
||||
const well_conn_collection_type * connections);
|
||||
void well_segment_collection_add_branches( const well_segment_collection_type * segment_collection ,
|
||||
well_branch_collection_type * branches );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -114,4 +114,7 @@ bool well_branch_collection_add_start_segment( well_branch_collection_type * bra
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
28
ThirdParty/Ert/devel/libecl_well/src/well_conn.c
vendored
28
ThirdParty/Ert/devel/libecl_well/src/well_conn.c
vendored
@ -30,7 +30,7 @@
|
||||
|
||||
|
||||
#define WELL_CONN_NORMAL_WELL_SEGMENT_ID -999
|
||||
#define ECLIPSE_NORMAL_WELL_SEGMENT_ID -1
|
||||
//#define ECLIPSE_NORMAL_WELL_SEGMENT_ID -1
|
||||
|
||||
/*
|
||||
Observe that when the (ijk) values are initialized they are
|
||||
@ -47,7 +47,7 @@ struct well_conn_struct {
|
||||
int k;
|
||||
well_conn_dir_enum dir;
|
||||
bool open;
|
||||
int segment; // -1: Ordinary well
|
||||
int segment_id; // -1: Ordinary well
|
||||
bool matrix_connection; // k >= nz => fracture (and k -= nz )
|
||||
};
|
||||
|
||||
@ -62,7 +62,7 @@ bool well_conn_equal( const well_conn_type *conn1 , const well_conn_type * conn
|
||||
|
||||
|
||||
bool well_conn_MSW( const well_conn_type * conn ) {
|
||||
if (conn->segment == WELL_CONN_NORMAL_WELL_SEGMENT_ID)
|
||||
if (conn->segment_id == WELL_CONN_NORMAL_WELL_SEGMENT_ID)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
@ -91,10 +91,10 @@ static well_conn_type * well_conn_alloc__( int i , int j , int k , well_conn_dir
|
||||
conn->dir = dir;
|
||||
|
||||
conn->matrix_connection = matrix_connection;
|
||||
if (segment_id == ECLIPSE_NORMAL_WELL_SEGMENT_ID)
|
||||
conn->segment = WELL_CONN_NORMAL_WELL_SEGMENT_ID;
|
||||
if (segment_id == CONN_NORMAL_WELL_SEGMENT_VALUE)
|
||||
conn->segment_id = WELL_CONN_NORMAL_WELL_SEGMENT_ID;
|
||||
else
|
||||
conn->segment = segment_id;
|
||||
conn->segment_id = segment_id;
|
||||
|
||||
return conn;
|
||||
} else {
|
||||
@ -110,8 +110,8 @@ well_conn_type * well_conn_alloc( int i , int j , int k , well_conn_dir_enum dir
|
||||
|
||||
|
||||
|
||||
well_conn_type * well_conn_alloc_MSW( int i , int j , int k , well_conn_dir_enum dir , bool open, int segment) {
|
||||
return well_conn_alloc__(i , j , k , dir , open , segment , true );
|
||||
well_conn_type * well_conn_alloc_MSW( int i , int j , int k , well_conn_dir_enum dir , bool open, int segment_id) {
|
||||
return well_conn_alloc__(i , j , k , dir , open , segment_id , true );
|
||||
}
|
||||
|
||||
|
||||
@ -122,8 +122,8 @@ well_conn_type * well_conn_alloc_fracture( int i , int j , int k , well_conn_dir
|
||||
|
||||
|
||||
|
||||
well_conn_type * well_conn_alloc_fracture_MSW( int i , int j , int k , well_conn_dir_enum dir , bool open, int segment) {
|
||||
return well_conn_alloc__(i , j , k , dir , open , segment , false);
|
||||
well_conn_type * well_conn_alloc_fracture_MSW( int i , int j , int k , well_conn_dir_enum dir , bool open, int segment_id) {
|
||||
return well_conn_alloc__(i , j , k , dir , open , segment_id , false);
|
||||
}
|
||||
|
||||
|
||||
@ -145,7 +145,7 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw ,
|
||||
int i = ecl_kw_iget_int( icon_kw , icon_offset + ICON_I_ITEM ) - 1;
|
||||
int j = ecl_kw_iget_int( icon_kw , icon_offset + ICON_J_ITEM ) - 1;
|
||||
int k = ecl_kw_iget_int( icon_kw , icon_offset + ICON_K_ITEM ) - 1;
|
||||
int segment = ecl_kw_iget_int( icon_kw , icon_offset + ICON_SEGMENT_ITEM ) - 1;
|
||||
int segment_id = ecl_kw_iget_int( icon_kw , icon_offset + ICON_SEGMENT_ITEM ) - ECLIPSE_WELL_SEGMENT_OFFSET + WELL_SEGMENT_OFFSET;
|
||||
bool matrix_connection = true;
|
||||
bool open;
|
||||
well_conn_dir_enum dir = well_conn_fracX;
|
||||
@ -199,7 +199,7 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw ,
|
||||
}
|
||||
}
|
||||
|
||||
conn = well_conn_alloc__(i,j,k,dir,open,segment,matrix_connection);
|
||||
conn = well_conn_alloc__(i,j,k,dir,open,segment_id,matrix_connection);
|
||||
|
||||
/**
|
||||
For multisegmented wells ONLY the global part of the restart
|
||||
@ -298,8 +298,8 @@ bool well_conn_open( const well_conn_type * conn ) {
|
||||
}
|
||||
|
||||
|
||||
int well_conn_get_segment( const well_conn_type * conn ) {
|
||||
return conn->segment;
|
||||
int well_conn_get_segment_id( const well_conn_type * conn ) {
|
||||
return conn->segment_id;
|
||||
}
|
||||
|
||||
bool well_conn_fracture_connection( const well_conn_type * conn) {
|
||||
|
@ -72,15 +72,15 @@ well_segment_type * well_segment_alloc(int segment_id , int outlet_segment_id ,
|
||||
}
|
||||
|
||||
|
||||
well_segment_type * well_segment_alloc_from_kw( const ecl_kw_type * iseg_kw , const ecl_kw_type * rseg_kw , const ecl_rsthead_type * header , int well_nr, int segment_id) {
|
||||
well_segment_type * well_segment_alloc_from_kw( const ecl_kw_type * iseg_kw , const ecl_kw_type * rseg_kw , const ecl_rsthead_type * header , int well_nr, int segment_index , int segment_id) {
|
||||
if (rseg_kw == NULL) {
|
||||
util_abort("%s: fatal internal error - tried to create well_segment instance without RSEG keyword.\n",__func__);
|
||||
return NULL;
|
||||
} else {
|
||||
const int iseg_offset = header->nisegz * ( header->nsegmx * well_nr + segment_id);
|
||||
const int rseg_offset = header->nrsegz * ( header->nsegmx * well_nr + segment_id);
|
||||
int outlet_segment_id = ecl_kw_iget_int( iseg_kw , iseg_offset + ISEG_OUTLET_ITEM ) - 1;
|
||||
int branch_id = ecl_kw_iget_int( iseg_kw , iseg_offset + ISEG_BRANCH_ITEM ) - 1;
|
||||
const int iseg_offset = header->nisegz * ( header->nsegmx * well_nr + segment_index);
|
||||
const int rseg_offset = header->nrsegz * ( header->nsegmx * well_nr + segment_index);
|
||||
int outlet_segment_id = ecl_kw_iget_int( iseg_kw , iseg_offset + ISEG_OUTLET_ITEM ) - ECLIPSE_WELL_SEGMENT_OFFSET + WELL_SEGMENT_OFFSET ; // -1
|
||||
int branch_id = ecl_kw_iget_int( iseg_kw , iseg_offset + ISEG_BRANCH_ITEM ) - ECLIPSE_WELL_BRANCH_OFFSET + WELL_BRANCH_OFFSET ; // -1
|
||||
const double * rseg_data = ecl_kw_iget_ptr( rseg_kw , rseg_offset );
|
||||
|
||||
well_segment_type * segment = well_segment_alloc( segment_id , outlet_segment_id , branch_id , rseg_data);
|
||||
@ -116,7 +116,7 @@ void well_segment_free__(void * arg) {
|
||||
|
||||
|
||||
bool well_segment_active( const well_segment_type * segment ) {
|
||||
if (segment->branch_id == ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE)
|
||||
if (segment->branch_id == WELL_SEGMENT_BRANCH_INACTIVE_VALUE)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
@ -124,7 +124,7 @@ bool well_segment_active( const well_segment_type * segment ) {
|
||||
|
||||
|
||||
bool well_segment_main_stem( const well_segment_type * segment ) {
|
||||
if (segment->branch_id == ECLIPSE_WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE)
|
||||
if (segment->branch_id == WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@ -132,7 +132,7 @@ bool well_segment_main_stem( const well_segment_type * segment ) {
|
||||
|
||||
|
||||
bool well_segment_nearest_wellhead( const well_segment_type * segment ) {
|
||||
if (segment->outlet_segment_id == ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE)
|
||||
if (segment->outlet_segment_id == WELL_SEGMENT_OUTLET_END_VALUE)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@ -195,7 +195,7 @@ bool well_segment_has_global_grid_connections( const well_segment_type * segment
|
||||
|
||||
|
||||
bool well_segment_add_connection( well_segment_type * segment , const char * grid_name , well_conn_type * conn) {
|
||||
int conn_segment_id = well_conn_get_segment( conn );
|
||||
int conn_segment_id = well_conn_get_segment_id( conn );
|
||||
if (conn_segment_id == segment->segment_id) {
|
||||
if (!well_segment_has_grid_connections( segment , grid_name ))
|
||||
hash_insert_hash_owned_ref( segment->connections , grid_name , well_conn_collection_alloc() , well_conn_collection_free__ );
|
||||
|
@ -65,7 +65,7 @@ int well_segment_collection_get_size( const well_segment_collection_type * segme
|
||||
void well_segment_collection_add( well_segment_collection_type * segment_collection , well_segment_type * segment) {
|
||||
int segment_id = well_segment_get_id( segment );
|
||||
int current_index = int_vector_safe_iget( segment_collection->segment_index_map , segment_id );
|
||||
if (current_index >= 0)
|
||||
if (current_index >= 0)
|
||||
vector_iset_owned_ref( segment_collection->__segment_storage , current_index , segment , well_segment_free__);
|
||||
else {
|
||||
int new_index = vector_get_size(segment_collection->__segment_storage);
|
||||
@ -111,10 +111,11 @@ int well_segment_collection_load_from_kw( well_segment_collection_type * segment
|
||||
int segments_added = 0;
|
||||
|
||||
if (segment_well_nr != IWEL_SEGMENTED_WELL_NR_NORMAL_VALUE) {
|
||||
int segment_id;
|
||||
for (segment_id = 0; segment_id < rst_head->nsegmx; segment_id++) {
|
||||
well_segment_type * segment = well_segment_alloc_from_kw( iseg_kw , rseg_kw , rst_head , segment_well_nr , segment_id );
|
||||
|
||||
int segment_index;
|
||||
for (segment_index = 0; segment_index < rst_head->nsegmx; segment_index++) {
|
||||
int segment_id = segment_index + WELL_SEGMENT_OFFSET;
|
||||
well_segment_type * segment = well_segment_alloc_from_kw( iseg_kw , rseg_kw , rst_head , segment_well_nr , segment_index , segment_id );
|
||||
|
||||
if (well_segment_active( segment )) {
|
||||
well_segment_collection_add( segment_collection , segment );
|
||||
segments_added++;
|
||||
@ -122,7 +123,6 @@ int well_segment_collection_load_from_kw( well_segment_collection_type * segment
|
||||
well_segment_free( segment );
|
||||
}
|
||||
}
|
||||
|
||||
return segments_added;
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ void well_segment_collection_add_connections(well_segment_collection_type * segm
|
||||
for (iconn = 0; iconn < well_conn_collection_get_size( connections ); iconn++) {
|
||||
well_conn_type * conn = well_conn_collection_iget( connections , iconn );
|
||||
if (well_conn_MSW( conn )) {
|
||||
int segment_id = well_conn_get_segment( conn );
|
||||
int segment_id = well_conn_get_segment_id( conn );
|
||||
well_segment_type * segment = well_segment_collection_get( segment_collection , segment_id );
|
||||
well_segment_add_connection( segment , grid_name , conn );
|
||||
}
|
||||
@ -167,3 +167,6 @@ void well_segment_collection_add_branches( const well_segment_collection_type *
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -92,7 +92,7 @@ int main(int argc , char ** argv) {
|
||||
test_assert_int_equal( i , well_conn_get_i( conn ));
|
||||
test_assert_int_equal( j , well_conn_get_j( conn ));
|
||||
test_assert_int_equal( k , well_conn_get_k( conn ));
|
||||
test_assert_int_equal( segment , well_conn_get_segment( conn ));
|
||||
test_assert_int_equal( segment , well_conn_get_segment_id( conn ));
|
||||
test_assert_bool_equal( open , well_conn_open( conn ));
|
||||
test_assert_int_equal( dir , well_conn_get_dir( conn ));
|
||||
test_assert_true( well_conn_MSW( conn ));
|
||||
@ -109,7 +109,7 @@ int main(int argc , char ** argv) {
|
||||
test_assert_int_equal( i , well_conn_get_i( conn ));
|
||||
test_assert_int_equal( j , well_conn_get_j( conn ));
|
||||
test_assert_int_equal( k , well_conn_get_k( conn ));
|
||||
test_assert_int_equal( segment , well_conn_get_segment( conn ));
|
||||
test_assert_int_equal( segment , well_conn_get_segment_id( conn ));
|
||||
test_assert_bool_equal( open , well_conn_open( conn ));
|
||||
test_assert_int_equal( dir , well_conn_get_dir( conn ));
|
||||
test_assert_true( well_conn_MSW( conn ));
|
||||
|
@ -43,7 +43,7 @@ int main(int argc , char ** argv) {
|
||||
{
|
||||
int segment_id = 78;
|
||||
int outlet_segment_id = 100;
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE;
|
||||
int branch_nr = WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE;
|
||||
well_segment_type * ws = well_segment_alloc(segment_id , outlet_segment_id , branch_nr, rseg_data);
|
||||
|
||||
test_assert_true( well_segment_is_instance( ws ));
|
||||
@ -66,7 +66,7 @@ int main(int argc , char ** argv) {
|
||||
}
|
||||
|
||||
{
|
||||
int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int outlet_segment_id = WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int branch_nr = 100;
|
||||
well_segment_type * ws = well_segment_alloc(12 , outlet_segment_id , branch_nr, rseg_data);
|
||||
|
||||
@ -76,17 +76,17 @@ int main(int argc , char ** argv) {
|
||||
|
||||
|
||||
{
|
||||
int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
|
||||
int outlet_segment_id = WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int branch_nr = WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
|
||||
well_segment_type * ws = well_segment_alloc(89 , outlet_segment_id , branch_nr, rseg_data);
|
||||
|
||||
test_assert_false( well_segment_active( ws ));
|
||||
}
|
||||
|
||||
{
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE;
|
||||
int branch_nr = WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE;
|
||||
int outlet_id = 0;
|
||||
well_segment_type * outlet = well_segment_alloc(outlet_id , ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE , branch_nr, rseg_data);
|
||||
well_segment_type * outlet = well_segment_alloc(outlet_id , WELL_SEGMENT_OUTLET_END_VALUE , branch_nr, rseg_data);
|
||||
well_segment_type * ws = well_segment_alloc(100 , outlet_id , branch_nr, rseg_data);
|
||||
|
||||
test_assert_true( well_segment_link( ws , outlet ));
|
||||
@ -99,9 +99,9 @@ int main(int argc , char ** argv) {
|
||||
}
|
||||
|
||||
{
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE;
|
||||
int branch_nr = WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE;
|
||||
int outlet_id = 0;
|
||||
well_segment_type * outlet = well_segment_alloc(outlet_id , ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE , branch_nr , rseg_data);
|
||||
well_segment_type * outlet = well_segment_alloc(outlet_id , WELL_SEGMENT_OUTLET_END_VALUE , branch_nr , rseg_data);
|
||||
well_segment_type * ws = well_segment_alloc(100 , outlet_id + 1, branch_nr, rseg_data);
|
||||
|
||||
test_assert_false( well_segment_link( ws , outlet ));
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_segment_collection.h>
|
||||
|
||||
|
||||
@ -37,8 +37,8 @@ int main(int argc , char ** argv) {
|
||||
test_assert_int_equal( well_segment_collection_get_size( sc ) , 0 );
|
||||
|
||||
{
|
||||
int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
|
||||
int outlet_segment_id = WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int branch_nr = WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
|
||||
well_segment_type * ws = well_segment_alloc(89 , outlet_segment_id , branch_nr, rseg_data);
|
||||
|
||||
well_segment_collection_add( sc , ws );
|
||||
@ -51,8 +51,8 @@ int main(int argc , char ** argv) {
|
||||
}
|
||||
|
||||
{
|
||||
int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
|
||||
int outlet_segment_id = WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int branch_nr = WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
|
||||
well_segment_type * ws = well_segment_alloc(90 , outlet_segment_id , branch_nr , rseg_data);
|
||||
|
||||
well_segment_collection_add( sc , ws );
|
||||
@ -67,8 +67,8 @@ int main(int argc , char ** argv) {
|
||||
}
|
||||
|
||||
{
|
||||
int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
|
||||
int outlet_segment_id = WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int branch_nr = WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
|
||||
well_segment_type * ws = well_segment_alloc(89 , outlet_segment_id , branch_nr, rseg_data);
|
||||
|
||||
well_segment_collection_add( sc , ws );
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_segment.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
@ -36,7 +37,7 @@ int main(int argc , char ** argv) {
|
||||
{
|
||||
int segment_id = 78;
|
||||
int outlet_segment_id = 100;
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE;
|
||||
int branch_nr = WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE;
|
||||
well_segment_type * ws = well_segment_alloc(segment_id , outlet_segment_id , branch_nr, rseg_data);
|
||||
well_conn_type * conn1 = well_conn_alloc_MSW(1,1,1,true,well_conn_dirX,segment_id);
|
||||
well_conn_type * conn2 = well_conn_alloc_MSW(1,1,1,true,well_conn_dirX,segment_id + 1);
|
||||
|
@ -52,11 +52,12 @@ int main(int argc , char ** argv) {
|
||||
well_segment_collection_type * segments = well_segment_collection_alloc();
|
||||
int seg_well_nr = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_SEGMENTED_WELL_NR_ITEM) - 1; // -1: Ordinary well.
|
||||
if (seg_well_nr >= 0) {
|
||||
int segment_id;
|
||||
int segment_index;
|
||||
int segment_count = 0;
|
||||
|
||||
for (segment_id = 0; segment_id < rst_head->nsegmx; segment_id++) {
|
||||
well_segment_type * segment = well_segment_alloc_from_kw( iseg_kw , rseg_kw , rst_head , seg_well_nr , segment_id );
|
||||
for (segment_index = 0; segment_index < rst_head->nsegmx; segment_index++) {
|
||||
int segment_id = segment_index + WELL_SEGMENT_OFFSET;
|
||||
well_segment_type * segment = well_segment_alloc_from_kw( iseg_kw , rseg_kw , rst_head , seg_well_nr , segment_index , segment_id );
|
||||
|
||||
test_assert_true( well_segment_is_instance( segment ));
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <ert/util/bool_vector.h>
|
||||
#include <ert/util/msg.h>
|
||||
#include <ert/util/vector.h>
|
||||
#include <ert/util/matrix.h>
|
||||
#include <ert/util/type_vector_functions.h>
|
||||
|
||||
#include <ert/plot/plot.h>
|
||||
@ -52,6 +53,8 @@
|
||||
#include <ert/enkf/plot_config.h>
|
||||
#include <ert/enkf/member_config.h>
|
||||
#include <ert/enkf/enkf_analysis.h>
|
||||
#include <ert/enkf/obs_tstep_list.h>
|
||||
#include <ert/enkf/pca_plot_data.h>
|
||||
|
||||
#include <enkf_tui_util.h>
|
||||
#include <enkf_tui_plot.h>
|
||||
@ -60,100 +63,78 @@
|
||||
#include <enkf_tui_plot_util.h>
|
||||
|
||||
|
||||
void enkf_tui_QC_plot_get_PC( enkf_main_type * enkf_main , int step1 , int step2 , state_enum state , const local_obsset_type * obsset ,
|
||||
double truncation , int ncomp ,
|
||||
matrix_type * PC , matrix_type * PC_obs) {
|
||||
|
||||
bool_vector_type * ens_mask = bool_vector_alloc(0 , false);
|
||||
obs_data_type * obs_data = obs_data_alloc();
|
||||
analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
|
||||
int_vector_type * step_list = int_vector_alloc(0,0);
|
||||
enkf_fs_type * source_fs = enkf_main_get_fs( enkf_main);
|
||||
state_map_type * state_map = enkf_fs_get_state_map(source_fs);
|
||||
int_vector_type * ens_active_list;
|
||||
meas_data_type * meas_data;
|
||||
|
||||
state_map_select_matching(state_map , ens_mask , STATE_HAS_DATA);
|
||||
ens_active_list = bool_vector_alloc_active_list(ens_mask);
|
||||
meas_data = meas_data_alloc(ens_active_list);
|
||||
{
|
||||
for (int step =step1; step <= step2; step++)
|
||||
int_vector_append( step_list , step );
|
||||
}
|
||||
|
||||
obs_data_reset( obs_data );
|
||||
meas_data_reset( meas_data );
|
||||
void enkf_tui_QC_plot_PC_list( void * arg ) {
|
||||
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
|
||||
stringlist_type * all_obs_keys = enkf_obs_alloc_keylist( enkf_main_get_obs( enkf_main ));
|
||||
stringlist_type * obs_keys = stringlist_alloc_new();
|
||||
|
||||
{
|
||||
double std_cutoff = analysis_config_get_std_cutoff( analysis_config );
|
||||
double alpha = analysis_config_get_alpha( analysis_config );
|
||||
|
||||
enkf_obs_get_obs_and_measure(enkf_main_get_obs( enkf_main ),
|
||||
source_fs ,
|
||||
step_list ,
|
||||
state,
|
||||
ens_active_list ,
|
||||
(const enkf_state_type **) enkf_main_get_ensemble( enkf_main ),
|
||||
meas_data ,
|
||||
obs_data ,
|
||||
obsset );
|
||||
|
||||
enkf_analysis_deactivate_outliers( obs_data , meas_data , std_cutoff , alpha);
|
||||
char * keys_input;
|
||||
util_printf_prompt("Observation keys (wildcards allowed) - [default: all]", PROMPT_LEN, '=', "=> ");
|
||||
keys_input = util_alloc_stdin_line();
|
||||
if (keys_input)
|
||||
{
|
||||
stringlist_type * pattern_list = stringlist_alloc_from_split(keys_input, " ,");
|
||||
for (int i = 0; i < stringlist_get_size(pattern_list); i++)
|
||||
{
|
||||
const char * pattern = stringlist_iget(pattern_list, i);
|
||||
stringlist_append_matching_elements(obs_keys, all_obs_keys, pattern);
|
||||
}
|
||||
free(keys_input);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (stringlist_get_size(obs_keys) > 0)
|
||||
{
|
||||
int active_size = obs_data_get_active_size( obs_data );
|
||||
matrix_type * S = meas_data_allocS( meas_data , active_size );
|
||||
matrix_type * dObs = obs_data_allocdObs( obs_data , active_size );
|
||||
const int last_report = enkf_main_get_history_length(enkf_main);
|
||||
vector_type * PC_list = vector_alloc_new();
|
||||
const int ncomp = 1;
|
||||
|
||||
obs_data_scale( obs_data , S , NULL , NULL , NULL , dObs );
|
||||
enkf_main_get_PC( enkf_main , S , dObs , local_obsset_get_name( obsset ) , step1 , step2 , truncation , ncomp , PC , PC_obs );
|
||||
|
||||
matrix_free( S );
|
||||
matrix_free( dObs );
|
||||
}
|
||||
for (int iobs = 0; iobs < stringlist_get_size(obs_keys); iobs++)
|
||||
{
|
||||
local_obsdata_node_type * obsnode = local_obsdata_node_alloc(stringlist_iget(obs_keys, iobs));
|
||||
local_obsdata_type * obsdata = local_obsdata_alloc_wrapper(obsnode);
|
||||
local_obsdata_node_add_range(obsnode, 0, last_report);
|
||||
{
|
||||
pca_plot_data_type * plot_data = enkf_main_alloc_pca_plot_data(enkf_main, obsdata, ncomp);
|
||||
vector_append_owned_ref(PC_list, plot_data, pca_plot_data_free__);
|
||||
}
|
||||
local_obsdata_free(obsdata);
|
||||
}
|
||||
enkf_tui_plot_PC_list(enkf_main , PC_list);
|
||||
vector_free(PC_list);
|
||||
} else
|
||||
printf("Sorry: no observation keys mathced the pattern(s).\n");
|
||||
|
||||
bool_vector_free(ens_mask);
|
||||
int_vector_free( step_list );
|
||||
obs_data_free( obs_data );
|
||||
meas_data_free( meas_data );
|
||||
stringlist_free( obs_keys );
|
||||
stringlist_free( all_obs_keys );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void enkf_tui_QC_plot_PC( void * arg ) {
|
||||
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
|
||||
local_config_type * local_config = enkf_main_get_local_config( enkf_main );
|
||||
analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
|
||||
int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
const int last_report = enkf_main_get_history_length( enkf_main );
|
||||
int step1,step2;
|
||||
int ncomp;
|
||||
double truncation;
|
||||
double truncation_or_ncomp;
|
||||
local_obsdata_type * obsdata = local_obsdata_alloc("PCA Observations");
|
||||
char * keys_input;
|
||||
|
||||
state_enum state = FORECAST;
|
||||
const local_updatestep_type * update_step;
|
||||
local_obsset_type * obsset;
|
||||
|
||||
|
||||
enkf_tui_util_scanf_report_steps(last_report , PROMPT_LEN , &step1 , &step2);
|
||||
util_printf_prompt("Observation keys (wildcards allowed) - [default: all]" , PROMPT_LEN , '=' , "=> ");
|
||||
keys_input = util_alloc_stdin_line();
|
||||
|
||||
util_printf_prompt("Truncation: [0,1): Explained variance [1,ens_size): fixed" , PROMPT_LEN , '=' , "=> ");
|
||||
|
||||
{
|
||||
char * input = util_alloc_stdin_line();
|
||||
|
||||
if (input == NULL)
|
||||
return;
|
||||
else {
|
||||
double truncation_or_ncomp;
|
||||
if (util_sscanf_double( input , &truncation_or_ncomp)) {
|
||||
if (truncation_or_ncomp < 1) {
|
||||
truncation = truncation_or_ncomp;
|
||||
ncomp = -1;
|
||||
} else {
|
||||
truncation = -1;
|
||||
ncomp = util_int_min( (int) truncation_or_ncomp , ens_size );
|
||||
}
|
||||
} else {
|
||||
if (!util_sscanf_double( input , &truncation_or_ncomp)) {
|
||||
fprintf(stderr , "Failed to parse:%s as number \n",input);
|
||||
free( input );
|
||||
return;
|
||||
@ -163,41 +144,57 @@ void enkf_tui_QC_plot_PC( void * arg ) {
|
||||
free( input );
|
||||
}
|
||||
|
||||
update_step = local_config_iget_updatestep( local_config , step2 );
|
||||
{
|
||||
int obsset_nr = 0;
|
||||
if (local_updatestep_get_num_ministep( update_step) > 1) {
|
||||
stringlist_type * obsset_list = stringlist_alloc_new();
|
||||
for (int i =0; i < local_updatestep_get_num_ministep( update_step ); i++) {
|
||||
local_obsset_type * obsset = local_updatestep_iget_obsset( update_step , i );
|
||||
stringlist_append_ref( obsset_list , local_obsset_get_name( obsset ));
|
||||
|
||||
printf(" %02d : %s \n", i +1 , local_obsset_get_name( obsset ));
|
||||
}
|
||||
stringlist_free( obsset_list );
|
||||
stringlist_type * all_keys = enkf_obs_alloc_keylist( enkf_main_get_obs( enkf_main ));
|
||||
stringlist_type * obs_keys = stringlist_alloc_new();
|
||||
|
||||
obsset_nr = util_scanf_int( "Choose observation set" , PROMPT_LEN );
|
||||
obsset_nr--;
|
||||
}
|
||||
if ((obsset_nr < 0) || (obsset_nr >= local_updatestep_get_num_ministep( update_step)))
|
||||
return;
|
||||
|
||||
obsset = local_updatestep_iget_obsset( update_step , obsset_nr );
|
||||
}
|
||||
|
||||
{
|
||||
if (keys_input) {
|
||||
stringlist_type * input_keys = stringlist_alloc_from_split( keys_input , " ");
|
||||
int i;
|
||||
for (i=0; i < stringlist_get_size( input_keys ); i++)
|
||||
stringlist_append_matching_elements( obs_keys , all_keys , stringlist_iget( input_keys , i ));
|
||||
stringlist_free( input_keys );
|
||||
} else
|
||||
stringlist_deep_copy( obs_keys , all_keys );
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
int iobs;
|
||||
|
||||
for (iobs = 0; iobs < stringlist_get_size( obs_keys); iobs++) {
|
||||
const char * obs_key = stringlist_iget( obs_keys , iobs );
|
||||
if (!local_obsdata_has_node( obsdata , obs_key )) {
|
||||
local_obsdata_node_type * obs_node = local_obsdata_node_alloc( obs_key );
|
||||
|
||||
local_obsdata_node_add_range( obs_node , step1 , step2 );
|
||||
local_obsdata_add_node( obsdata , obs_node );
|
||||
}
|
||||
}
|
||||
|
||||
stringlist_free( all_keys );
|
||||
stringlist_free( obs_keys );
|
||||
}
|
||||
}
|
||||
|
||||
if (local_obsdata_get_size( obsdata )) {
|
||||
matrix_type * PC = matrix_alloc(1,1);
|
||||
matrix_type * PC_obs = matrix_alloc(1,1);
|
||||
analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
|
||||
char * plot_name = util_alloc_sprintf(analysis_config_get_PC_filename( analysis_config ) ,
|
||||
step1 , step2 , local_obsset_get_name( obsset ));
|
||||
step1 , step2 , "obs");
|
||||
|
||||
pca_plot_data_type * plot_data = enkf_main_alloc_pca_plot_data( enkf_main , obsdata , truncation_or_ncomp);
|
||||
|
||||
enkf_tui_QC_plot_get_PC( enkf_main , step1 , step2 , state , obsset , truncation , ncomp , PC , PC_obs );
|
||||
enkf_tui_plot_PC( enkf_main , plot_name , PC , PC_obs );
|
||||
enkf_tui_plot_PC( enkf_main , plot_name , plot_data );
|
||||
|
||||
free( plot_name );
|
||||
matrix_free( PC );
|
||||
matrix_free( PC_obs );
|
||||
pca_plot_data_free( plot_data );
|
||||
}
|
||||
local_obsdata_free( obsdata );
|
||||
}
|
||||
|
||||
|
||||
@ -221,11 +218,18 @@ void enkf_tui_QC_menu(void * arg) {
|
||||
|
||||
{
|
||||
menu_type * menu = menu_alloc("Quality check of prior" , "Back" , "bB");
|
||||
menu_item_type * plot_PC_item = menu_add_item( menu , "Plot of prior principal components" , "pP" , enkf_tui_QC_plot_PC , enkf_main , NULL);
|
||||
menu_item_type * plot_PC_item = menu_add_item( menu , "Plot of prior principal components" , "pP" ,
|
||||
enkf_tui_QC_plot_PC , enkf_main , NULL);
|
||||
|
||||
menu_item_type * plot_PC_list_item = menu_add_item( menu , "Plot first principal component for all observations" , "aA" ,
|
||||
enkf_tui_QC_plot_PC_list, enkf_main , NULL);
|
||||
|
||||
menu_item_type * run_QC_workflow_item = menu_add_item( menu , "Run QC workflow" , "rR" , enkf_tui_QC_run_workflow , enkf_main , NULL);
|
||||
|
||||
if (!enkf_main_have_obs( enkf_main ))
|
||||
if (!enkf_main_have_obs( enkf_main )) {
|
||||
menu_item_disable( plot_PC_item );
|
||||
menu_item_disable( plot_PC_list_item );
|
||||
}
|
||||
|
||||
if (!enkf_main_has_QC_workflow( enkf_main ))
|
||||
menu_item_disable( run_QC_workflow_item );
|
||||
|
@ -56,6 +56,7 @@
|
||||
#include <ert/enkf/time_map.h>
|
||||
#include <ert/enkf/ert_report_list.h>
|
||||
#include <ert/enkf/ecl_refcase_list.h>
|
||||
#include <ert/enkf/pca_plot_data.h>
|
||||
|
||||
#include <ert_tui_const.h>
|
||||
#include <enkf_tui_util.h>
|
||||
@ -88,32 +89,84 @@ static void __plot_add_data(plot_type * plot , const char * label , int N , cons
|
||||
|
||||
|
||||
|
||||
void enkf_tui_plot_PC( enkf_main_type * enkf_main , const char * plot_name , const matrix_type * PC , const matrix_type * PC_obs) {
|
||||
|
||||
|
||||
void enkf_tui_plot_PC_list( enkf_main_type * enkf_main , const vector_type * PC_list ) {
|
||||
plot_config_type * plot_config = enkf_main_get_plot_config( enkf_main );
|
||||
char * plot_file = enkf_tui_plot_alloc_plot_file( plot_config , enkf_main_get_current_fs( enkf_main ), "PC_list" );
|
||||
plot_type * plot = enkf_tui_plot_alloc(plot_config ,
|
||||
"Standardized PC value " ,
|
||||
"Observation #",
|
||||
"Principle components" ,
|
||||
plot_file);
|
||||
|
||||
int num_obs = vector_get_size( PC_list );
|
||||
int iobs;
|
||||
for (iobs = 0; iobs < num_obs; iobs++) {
|
||||
const pca_plot_data_type * pca_data = vector_iget_const( PC_list , iobs );
|
||||
const pca_plot_vector_type * pca_vector = pca_plot_data_iget_vector( pca_data , 0 );
|
||||
int ens_size = pca_plot_vector_get_size( pca_vector );
|
||||
{
|
||||
char * data_label = util_alloc_sprintf("%s - simulated" , pca_plot_data_get_name( pca_data ));
|
||||
plot_dataset_type * sim_data = plot_alloc_new_dataset( plot , data_label , PLOT_XY );
|
||||
plot_dataset_set_style( sim_data , POINTS );
|
||||
plot_dataset_set_point_color( sim_data , BLUE);
|
||||
for (int iens = 0; iens < ens_size; iens++)
|
||||
plot_dataset_append_point_xy( sim_data ,
|
||||
pca_plot_vector_iget_sim_value( pca_vector , iens ),
|
||||
iobs );
|
||||
free( data_label );
|
||||
}
|
||||
{
|
||||
char * obs_label = util_alloc_sprintf("%s - obs" , pca_plot_data_get_name( pca_data ));
|
||||
plot_dataset_type * obs_data = plot_alloc_new_dataset( plot , obs_label , PLOT_XY );
|
||||
plot_dataset_set_style( obs_data , POINTS );
|
||||
plot_dataset_set_point_color( obs_data , RED);
|
||||
plot_dataset_append_point_xy( obs_data , pca_plot_vector_get_obs_value( pca_vector ) , iobs );
|
||||
free( obs_label );
|
||||
}
|
||||
// POsition of text is not considered when the autorange is applied; i.e. with
|
||||
// fixed coordinates it might fall outside the clipping region ...
|
||||
plot_add_text( plot , -0.75 , iobs , 0.35 , pca_plot_data_get_name( pca_data ));
|
||||
}
|
||||
enkf_tui_show_plot( plot , plot_config , plot_file ); /* Frees the plot - logical ehhh. */
|
||||
free( plot_file );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void enkf_tui_plot_PC( enkf_main_type * enkf_main , const char * plot_name , const pca_plot_data_type * plot_data) {
|
||||
plot_config_type * plot_config = enkf_main_get_plot_config( enkf_main );
|
||||
char * plot_file = enkf_tui_plot_alloc_plot_file( plot_config , enkf_main_get_current_fs( enkf_main ), plot_name );
|
||||
plot_type * plot = enkf_tui_plot_alloc(plot_config , "PC number", /* y akse */ "Standardized PC value " , "Principle components" , plot_file);
|
||||
|
||||
|
||||
{
|
||||
const int num_PC = matrix_get_rows( PC );
|
||||
const int ens_size = matrix_get_columns( PC );
|
||||
const int num_PC = pca_plot_data_get_size( plot_data );
|
||||
const int ens_size = pca_plot_data_get_ens_size( plot_data );
|
||||
int ipc, iens;
|
||||
|
||||
{
|
||||
plot_dataset_type * sim_data = plot_alloc_new_dataset( plot , "simulated" , PLOT_XY );
|
||||
plot_dataset_set_style( sim_data , POINTS );
|
||||
plot_dataset_set_point_color( sim_data , BLUE);
|
||||
for (ipc = 0; ipc < num_PC; ipc++)
|
||||
for (ipc = 0; ipc < num_PC; ipc++) {
|
||||
const pca_plot_vector_type * pca_vector = pca_plot_data_iget_vector( plot_data , ipc );
|
||||
for (iens =0; iens < ens_size; iens++)
|
||||
plot_dataset_append_point_xy( sim_data , (ipc + 1) , matrix_iget( PC , ipc , iens ));
|
||||
plot_dataset_append_point_xy( sim_data ,
|
||||
(ipc + 1) ,
|
||||
pca_plot_vector_iget_sim_value( pca_vector , iens ));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
plot_dataset_type * obs_data = plot_alloc_new_dataset( plot , "observation" , PLOT_XY );
|
||||
plot_dataset_set_style( obs_data , POINTS );
|
||||
plot_dataset_set_point_color( obs_data , RED);
|
||||
for (ipc = 0; ipc < num_PC; ipc++)
|
||||
plot_dataset_append_point_xy( obs_data , (ipc + 1) , matrix_iget( PC_obs , ipc , 0 ));
|
||||
for (ipc = 0; ipc < num_PC; ipc++) {
|
||||
const pca_plot_vector_type * pca_vector = pca_plot_data_iget_vector( plot_data , ipc );
|
||||
plot_dataset_append_point_xy( obs_data , (ipc + 1) , pca_plot_vector_get_obs_value( pca_vector ));
|
||||
}
|
||||
}
|
||||
}
|
||||
enkf_tui_show_plot( plot , plot_config , plot_file ); /* Frees the plot - logical ehhh. */
|
||||
|
@ -21,12 +21,15 @@
|
||||
|
||||
|
||||
#include <ert/util/matrix.h>
|
||||
#include <ert/util/vector.h>
|
||||
|
||||
#include <ert/enkf/pca_plot_data.h>
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
|
||||
void enkf_tui_plot_simple_menu(void * );
|
||||
void enkf_tui_plot_menu(void * );
|
||||
void enkf_tui_plot_PC( enkf_main_type * enkf_main , const char * plot_name , const matrix_type * PC , const matrix_type * PC_obs);
|
||||
void enkf_tui_plot_PC( enkf_main_type * enkf_main , const char * plot_name , const pca_plot_data_type * plot_data);
|
||||
void enkf_tui_plot_PC_list( enkf_main_type * enkf_main , const vector_type * PC_list );
|
||||
void enkf_tui_plot_reports(void *);
|
||||
void enkf_tui_plot_all_summary__( enkf_main_type * enkf_main , int iens1 , int iens2 , int step1 , int step2 , bool prediction_mode);
|
||||
|
||||
|
@ -318,12 +318,13 @@ void enkf_tui_run_menu(void * arg) {
|
||||
{
|
||||
const ecl_config_type * ecl_config = enkf_main_get_ecl_config( enkf_main );
|
||||
const model_config_type * model_config = enkf_main_get_model_config( enkf_main );
|
||||
const analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main);
|
||||
|
||||
menu_item_type * enkf_item = menu_add_item(menu , "Start EnKF run from beginning" , "sS" , enkf_tui_run_start , enkf_main , NULL);
|
||||
menu_item_type * restart_enkf_item = menu_add_item(menu , "Restart EnKF run from arbitrary state" , "rR" , enkf_tui_run_restart__ , enkf_main , NULL);
|
||||
menu_item_type * ES_item = menu_add_item(menu , "Integrated smoother update" , "iI" , enkf_tui_run_smoother , enkf_main , NULL);
|
||||
menu_item_type * it_ES_item = menu_add_item(menu , "Iterated smoother [RML-EnKF]" , "tT" , enkf_tui_run_iterated_ES , enkf_main , NULL);
|
||||
menu_item_type * one_more_item = menu_add_item(menu , "One more iteration" , "mM" , enkf_tui_run_one_more_iteration , enkf_main , NULL);
|
||||
menu_item_type * one_more_item = menu_add_item(menu , "One more iteration (disabled)" , "mM" , enkf_tui_run_one_more_iteration , enkf_main , NULL);
|
||||
|
||||
if (!ecl_config_has_schedule( ecl_config )) {
|
||||
menu_item_disable( enkf_item );
|
||||
@ -333,9 +334,20 @@ void enkf_tui_run_menu(void * arg) {
|
||||
if (!ecl_config_has_init_section( ecl_config ))
|
||||
menu_item_disable( enkf_item );
|
||||
|
||||
menu_item_disable( one_more_item );
|
||||
if (!analysis_config_get_module_option(analysis_config , ANALYSIS_ITERABLE)) {
|
||||
menu_item_disable( it_ES_item );
|
||||
menu_item_disable( one_more_item );
|
||||
} else {
|
||||
menu_item_disable( enkf_item );
|
||||
menu_item_disable( restart_enkf_item );
|
||||
menu_item_disable( ES_item );
|
||||
}
|
||||
|
||||
if (!model_config_has_history( model_config )) {
|
||||
menu_item_disable( it_ES_item );
|
||||
menu_item_disable( ES_item );
|
||||
menu_item_disable( one_more_item );
|
||||
}
|
||||
}
|
||||
menu_add_separator(menu);
|
||||
@ -367,5 +379,4 @@ void enkf_tui_run_menu(void * arg) {
|
||||
menu_add_item(menu , "Help" , "hH" , enkf_tui_help_menu_run , enkf_main , NULL);
|
||||
menu_run(menu);
|
||||
menu_free(menu);
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user