Merge pull request #16 from OPM/internal

Update master to version 0.9.2
This commit is contained in:
Magne Sjaastad 2013-02-11 05:16:44 -08:00
commit 4656b0b15b
1431 changed files with 227500 additions and 15054 deletions

59
.gitignore vendored
View File

@ -1,30 +1,29 @@
# editor backup files
*~
.\#*
# compiler output
*.o
# Octave plugins (compiled)
*.oct
# precompiled headers
*.gch
# Qt preprocessor
moc_*.cxx
qrc_*.cxx
# CMake
*.cmake
Makefile
CMakeFiles/
CMakeCache.txt
/Generated/
*.qrc.depends
# Unit testing
*_UnitTests
# Target program
/ApplicationCode/ResInsight
# editor backup files
*~
.\#*
# compiler output
*.o
# Octave plugins (compiled)
*.oct
# precompiled headers
*.gch
# Qt preprocessor
moc_*.cxx
qrc_*.cxx
# CMake
Makefile
CMakeFiles/
CMakeCache.txt
/Generated/
*.qrc.depends
# Unit testing
*_UnitTests
# Target program
/ApplicationCode/ResInsight

View File

@ -53,6 +53,8 @@
#include "cafUiProcess.h"
#include "RimUiTreeModelPdm.h"
#include "RiaImageCompareReporter.h"
#include "RiaImageFileCompare.h"
namespace caf
{
@ -66,6 +68,18 @@ void AppEnum< RIApplication::RINavigationPolicy >::setUp()
}
namespace RegTestNames
{
const QString generatedFolderName = "RegTestGeneratedImages";
const QString diffFolderName = "RegTestDiffImages";
const QString baseFolderName = "RegTestBaseImages";
const QString testProjectName = "RegressionTest.rip";
const QString testFolderFilter = "TestCase*";
const QString imageCompareExeName = "compare";
const QString reportFileName = "ResInsightRegressionTestReport.html";
};
//==================================================================================================
///
/// \class RIApplication
@ -214,6 +228,7 @@ bool RIApplication::loadProject(const QString& projectFileName)
m_project->fileName = projectFileName;
m_project->readFile();
m_project->fileName = projectFileName; // Make sure we overwrite the old filename read from the project file
if (m_project->projectFileVersionString().isEmpty())
{
@ -602,11 +617,23 @@ bool RIApplication::parseArguments()
bool openLatestProject = false;
QString projectFilename;
QStringList caseNames;
QString regressionTestPath;
enum ArgumentParsingType
{
PARSE_PROJECT_FILE_NAME,
PARSE_CASE_NAMES,
PARSE_START_DIR,
PARSE_REGRESSION_TEST_PATH,
PARSING_NONE
};
ArgumentParsingType argumentParsingType = PARSING_NONE;
bool isParsingProjectFile = false;
bool isParsingCaseNames = false;
bool isParsingStartDir = false;
bool showHelp = false;
bool isSaveSnapshotsForAllViews = false;
bool isRunRegressionTest = false;
bool isUpdateRegressionTest = false;
int i;
for (i = 1; i < arguments.size(); i++)
@ -627,44 +654,70 @@ bool RIApplication::parseArguments()
}
else if (arg.toLower() == "-project")
{
isParsingCaseNames = false;
isParsingProjectFile = true;
isParsingStartDir = false;
argumentParsingType = PARSE_PROJECT_FILE_NAME;
foundKnownOption = true;
}
else if (arg.toLower() == "-case")
{
isParsingCaseNames = true;
isParsingProjectFile = false;
isParsingStartDir = false;
argumentParsingType = PARSE_CASE_NAMES;
foundKnownOption = true;
}
else if (arg.toLower() == "-startdir")
{
isParsingCaseNames = false;
isParsingProjectFile = false;
isParsingStartDir = true;
argumentParsingType = PARSE_START_DIR;
foundKnownOption = true;
}
else if (arg.toLower() == "-savesnapshots")
{
isSaveSnapshotsForAllViews = true;
foundKnownOption = true;
}
else if (arg.toLower() == "-regressiontest")
{
isRunRegressionTest = true;
argumentParsingType = PARSE_REGRESSION_TEST_PATH;
foundKnownOption = true;
}
else if (arg.toLower() == "-updateregressiontestbase")
{
isUpdateRegressionTest = true;
argumentParsingType = PARSE_REGRESSION_TEST_PATH;
foundKnownOption = true;
}
if (!foundKnownOption)
{
if (isParsingProjectFile && QFile::exists(arg))
switch (argumentParsingType)
{
projectFilename = arg;
}
case PARSE_PROJECT_FILE_NAME:
if (QFile::exists(arg))
{
projectFilename = arg;
}
break;
case PARSE_CASE_NAMES:
{
caseNames.append(arg);
}
break;
if (isParsingCaseNames)
{
caseNames.append(arg);
}
if (isParsingStartDir)
{
m_startupDefaultDirectory = arg;
case PARSE_START_DIR:
{
m_startupDefaultDirectory = arg;
}
break;
case PARSE_REGRESSION_TEST_PATH:
{
regressionTestPath = arg;
}
}
}
}
@ -675,16 +728,33 @@ bool RIApplication::parseArguments()
helpText += "Copyright Statoil ASA, Ceetron AS 2011, 2012\n\n";
helpText +=
"\nParameter Description\n"
"\nParameter Description\n"
"-----------------------------------------------------------------\n"
"-last Open last used project\n"
"-project <filename> Open project file <filename>\n"
"-case <casename> Open Eclipse case <casename>\n"
" (do not include .GRID/.EGRID)\n"
"-startdir The default directory for open/save commands\n"
"-help \n"
"-? Displays help text\n"
"-last Open last used project\n"
"\n"
"-project <filename> Open project file <filename>\n"
"\n"
"-case <casename> Open Eclipse case <casename>\n"
" (do not include .GRID/.EGRID)\n"
"\n"
"-startdir The default directory for open/save commands\n"
"\n"
"-savesnapshots Save snapshot of all views to 'snapshots' folder in project file folder\n"
" Application closes after snapshots are written to file\n"
"\n"
"-regressiontest <folder> Run a regression test on all sub-folders starting with \"" + RegTestNames::testFolderFilter + "\" of the given folder: \n"
" " + RegTestNames::testProjectName + " files in the sub-folders will be opened and \n"
" snapshots of all the views is written to the sub-sub-folder " + RegTestNames::generatedFolderName + ". \n"
" Then difference images is generated in the sub-sub-folder " + RegTestNames::diffFolderName + " based \n"
" on the images in sub-sub-folder " + RegTestNames::baseFolderName + ".\n"
" The results are presented in " + RegTestNames::reportFileName + " that is\n"
" written in the given folder.\n"
"\n"
"-updateregressiontestbase <folder> For all sub-folders starting with \"" + RegTestNames::testFolderFilter + "\" of the given folder: \n"
" Copy the images in the sub-sub-folder " + RegTestNames::generatedFolderName + " to the sub-sub-folder\n"
" " + RegTestNames::baseFolderName + " after deleting " + RegTestNames::baseFolderName + " completely.\n"
"\n"
"-help, -? Displays help text\n"
"-----------------------------------------------------------------";
fprintf(stdout, "%s\n", helpText.toAscii().data());
@ -693,6 +763,26 @@ bool RIApplication::parseArguments()
return false;
}
if (isRunRegressionTest)
{
RIMainWindow* mainWnd = RIMainWindow::instance();
if (mainWnd)
{
mainWnd->hideAllDockWindows();
}
runRegressionTest(regressionTestPath);
return false;
}
if (isUpdateRegressionTest)
{
updateRegressionTest(regressionTestPath);
return false;
}
if (openLatestProject)
{
loadLastUsedProject();
@ -725,6 +815,15 @@ bool RIApplication::parseArguments()
}
}
if (m_project.notNull() && !m_project->fileName().isEmpty() && isSaveSnapshotsForAllViews)
{
saveSnapshotForAllViews("snapshots");
// Returning false will exit the application
return false;
}
return true;
}
@ -943,3 +1042,252 @@ void RIApplication::setDefaultFileDialogDirectory(const QString& dialogName, con
{
m_fileDialogDefaultDirectories[dialogName] = defaultDirectory;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::saveSnapshotPromtpForFilename()
{
QString startPath;
if (!m_project->fileName().isEmpty())
{
QFileInfo fi(m_project->fileName());
startPath = fi.absolutePath();
}
else
{
startPath = defaultFileDialogDirectory("IMAGE_SNAPSHOT");
}
startPath += "/image.png";
QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save File"), startPath, tr("Image files (*.bmp *.png * *.jpg)"));
if (fileName.isEmpty())
{
return;
}
// Remember the directory to next time
setDefaultFileDialogDirectory("IMAGE_SNAPSHOT", QFileInfo(fileName).absolutePath());
saveSnapshotAs(fileName);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::saveSnapshotAs(const QString& fileName)
{
if (m_activeReservoirView && m_activeReservoirView->viewer())
{
QImage image = m_activeReservoirView->viewer()->grabFrameBuffer();
if (image.save(fileName))
{
qDebug() << "Saved snapshot image to " << fileName;
}
else
{
qDebug() << "Error when trying to save snapshot image to " << fileName;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::copySnapshotToClipboard()
{
if (m_activeReservoirView && m_activeReservoirView->viewer())
{
QImage image = m_activeReservoirView->viewer()->grabFrameBuffer();
QClipboard* clipboard = QApplication::clipboard();
if (clipboard)
{
clipboard->setImage(image);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
{
RIMainWindow* mainWnd = RIMainWindow::instance();
if (!mainWnd) return;
if (m_project.isNull()) return;
if (m_project->fileName().isEmpty()) return;
QFileInfo fi(m_project->fileName());
QDir projectDir(fi.absolutePath());
if (!projectDir.exists(snapshotFolderName))
{
if (!projectDir.mkdir(snapshotFolderName)) return;
}
QString snapshotPath = projectDir.absolutePath();
snapshotPath += "/" + snapshotFolderName;
for (size_t i = 0; i < m_project->reservoirs().size(); ++i)
{
RimReservoir* ri = m_project->reservoirs()[i];
if (!ri) continue;
for (size_t j = 0; j < ri->reservoirViews().size(); j++)
{
RimReservoirView* riv = ri->reservoirViews()[j];
if (riv && riv->viewer())
{
setActiveReservoirView(riv);
RIViewer* viewer = riv->viewer();
mainWnd->setActiveViewer(viewer);
// Process all events to avoid a black image when grabbing frame buffer
QCoreApplication::processEvents();
QString fileName = ri->caseName() + "-" + riv->name();
QString absoluteFileName = caf::Utils::constructFullFileName(snapshotPath, fileName, ".png");
saveSnapshotAs(absoluteFileName);
}
}
}
}
void removeDirectoryWithContent(QDir dirToDelete )
{
QStringList files = dirToDelete.entryList();
for (int fIdx = 0; fIdx < files.size(); ++fIdx)
{
dirToDelete.remove(files[fIdx]);
}
dirToDelete.rmdir(".");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::runRegressionTest(const QString& testRootPath)
{
QString generatedFolderName = RegTestNames::generatedFolderName;
QString diffFolderName = RegTestNames::diffFolderName;
QString baseFolderName = RegTestNames::baseFolderName;
QString regTestProjectName = RegTestNames::testProjectName;
QString regTestFolderFilter = RegTestNames::testFolderFilter;
// Find all sub folders
QDir testDir(testRootPath); // If string is empty it will end up as cwd
testDir.setFilter(QDir::Dirs);
QStringList dirNameFilter;
dirNameFilter.append(regTestFolderFilter);
testDir.setNameFilters(dirNameFilter);
QFileInfoList folderList = testDir.entryInfoList();
// delete diff and generated images
for (int i = 0; i < folderList.size(); ++i)
{
QDir testCaseFolder(folderList[i].filePath());
QDir genDir(testCaseFolder.filePath(generatedFolderName));
removeDirectoryWithContent(genDir);
QDir diffDir(testCaseFolder.filePath(diffFolderName));
removeDirectoryWithContent(diffDir);
QDir baseDir(testCaseFolder.filePath(baseFolderName));
}
// Generate html report
RiaImageCompareReporter imageCompareReporter;
for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx)
{
QDir testCaseFolder(folderList[dirIdx].filePath());
QString testFolderName = testCaseFolder.dirName();
QString reportBaseFolderName = testCaseFolder.filePath(baseFolderName);
QString reportGeneratedFolderName = testCaseFolder.filePath(generatedFolderName);
QString reportDiffFolderName = testCaseFolder.filePath(diffFolderName);
imageCompareReporter.addImageDirectoryComparisonSet(testFolderName.toStdString(), reportBaseFolderName.toStdString(), reportGeneratedFolderName.toStdString(), reportDiffFolderName.toStdString());
}
imageCompareReporter.generateHTMLReport(testDir.filePath(RegTestNames::reportFileName).toStdString());
// Generate diff images
for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx)
{
QDir testCaseFolder(folderList[dirIdx].filePath());
if (testCaseFolder.exists(regTestProjectName))
{
loadProject(testCaseFolder.filePath(regTestProjectName));
saveSnapshotForAllViews(generatedFolderName);
QDir baseDir(testCaseFolder.filePath(baseFolderName));
QDir genDir(testCaseFolder.filePath(generatedFolderName));
QDir diffDir(testCaseFolder.filePath(diffFolderName));
if (!diffDir.exists()) testCaseFolder.mkdir(diffFolderName);
baseDir.setFilter(QDir::Files);
QStringList baseImageFileNames = baseDir.entryList();
for (int fIdx = 0; fIdx < baseImageFileNames.size(); ++fIdx)
{
QString fileName = baseImageFileNames[fIdx];
RiaImageFileCompare imgComparator(RegTestNames::imageCompareExeName);
bool ok = imgComparator.runComparison(genDir.filePath(fileName), baseDir.filePath(fileName), diffDir.filePath(fileName));
if (!ok)
{
qDebug() << "Error comparing :" << imgComparator.errorMessage() << "\n" << imgComparator.errorDetails();
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::updateRegressionTest(const QString& testRootPath)
{
// Find all sub folders
QDir testDir(testRootPath); // If string is empty it will end up as cwd
testDir.setFilter(QDir::Dirs);
QStringList dirNameFilter;
dirNameFilter.append(RegTestNames::testFolderFilter);
testDir.setNameFilters(dirNameFilter);
QFileInfoList folderList = testDir.entryInfoList();
for (int i = 0; i < folderList.size(); ++i)
{
QDir testCaseFolder(folderList[i].filePath());
QDir baseDir(testCaseFolder.filePath(RegTestNames::baseFolderName));
removeDirectoryWithContent(baseDir);
testCaseFolder.mkdir(RegTestNames::baseFolderName);
QDir genDir(testCaseFolder.filePath(RegTestNames::generatedFolderName));
QStringList imageFileNames = genDir.entryList();
for (int fIdx = 0; fIdx < imageFileNames.size(); ++fIdx)
{
QString fileName = imageFileNames[fIdx];
QFile::copy(genDir.filePath(fileName), baseDir.filePath(fileName));
}
}
}

View File

@ -89,6 +89,13 @@ public:
bool saveProjectAs(const QString& fileName);
bool saveProjectPromptForFileName();
bool closeProject(bool askToSaveIfDirty);
void copySnapshotToClipboard();
void saveSnapshotPromtpForFilename();
void saveSnapshotAs(const QString& fileName);
void saveSnapshotForAllViews(const QString& snapshotFolderName);
void runRegressionTest(const QString& testRootPath);
void updateRegressionTest(const QString& testRootPath );
void processNonGuiEvents();
@ -121,7 +128,7 @@ private:
private slots:
void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
private:
caf::PdmPointer<RimReservoirView> m_activeReservoirView;

View File

@ -0,0 +1,135 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaImageCompareReporter.h"
#include <iostream>
#include <fstream>
#include <QDir>
RiaImageCompareReporter::RiaImageCompareReporter(void)
{
}
RiaImageCompareReporter::~RiaImageCompareReporter(void)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaImageCompareReporter::addImageDirectoryComparisonSet(const std::string& title, const std::string& baseImageDir, const std::string& newImagesDir, const std::string& diffImagesDir)
{
m_directorySets.push_back(DirSet(title, baseImageDir, newImagesDir, diffImagesDir));
}
std::string removeCommonStart(const std::string& mask, const std::string& filename)
{
size_t i;
for (i = 0; i < mask.size() && i < filename.size(); ++i)
{
if (mask[i] != filename[i]) break;
}
return filename.substr(i);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaImageCompareReporter::generateHTMLReport(const std::string& fileName)
{
if (m_directorySets.size() == 0) return;
std::ofstream output(fileName.c_str());
if (!output)
{
std::cout << "Trouble opening test report file: " << fileName;
return;
}
std::string html;
html += "<html>\n";
html += "<head>\n";
html += "<title>Regression-Test Report</title>\n";
html += "</head>\n";
html += "\n";
html += "<body>\n";
html += "\n";
for (size_t dsIdx = 0; dsIdx < m_directorySets.size(); ++dsIdx)
{
std::vector<std::string> baseImageNames = getPngFilesInDirectory(m_directorySets[dsIdx].m_baseImageDir);
html += "<table>\n";
html += " <tr>\n";
html += " <td colspan=\"3\" bgcolor=\"darkblue\" height=\"40\"> <b><font color=\"white\" size=\"3\"> " + m_directorySets[dsIdx].m_title + " </font></b> </td>\n";
html += " </tr>\n";
std::string baseImageFolder = removeCommonStart(fileName, m_directorySets[dsIdx].m_baseImageDir );
std::string genImageFolder = removeCommonStart(fileName, m_directorySets[dsIdx].m_newImagesDir );
std::string diffImageFolder = removeCommonStart(fileName, m_directorySets[dsIdx].m_diffImagesDir);
for (size_t fIdx = 0; fIdx < baseImageNames.size(); ++fIdx)
{
html += " <tr>\n";
html += " <td colspan=\"3\" bgcolor=\"lightgray\"> " + baseImageNames[fIdx] + "</td>\n";
html += " </tr>\n";
html += " <tr>\n";
html += " <td> <img src=\"" + baseImageFolder + "/" + baseImageNames[fIdx] + "\" width=\"100%\" alt=\"" + baseImageFolder + "/" + baseImageNames[fIdx] + "\" > </td>\n";
html += " <td> <img src=\"" + genImageFolder + "/" + baseImageNames[fIdx] + "\" width=\"100%\" alt=\"" + genImageFolder + "/" + baseImageNames[fIdx] + "\" > </td>\n";
html += " <td> <img src=\"" + diffImageFolder + "/" + baseImageNames[fIdx] + "\" width=\"100%\" alt=\"" + diffImageFolder + "/" + baseImageNames[fIdx] + "\" > </td>\n";
html += " </tr>\n";
// A little air between images
html += " <tr> <td height=\"10\"> </td> </tr>\n";
}
html += "</table>\n";
html += "\n";
}
output << html;
}
//--------------------------------------------------------------------------------------------------
/// Retuns the names of the *.png files in a directory. The names are without path, but with extention
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RiaImageCompareReporter::getPngFilesInDirectory(const std::string& searchPath)
{
QDir searchDir(QString::fromStdString(searchPath));
searchDir.setFilter(QDir::Files);
//QStringList filter;
//filter.append("*.png");
//searchDir.setNameFilters(filter);
QStringList imageFiles = searchDir.entryList();
std::vector<std::string> fileNames;
for (int i = 0; i < imageFiles.size(); ++i)
{
fileNames.push_back(imageFiles[i].toStdString());
}
return fileNames;
}

View File

@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <string>
#include <vector>
class RiaImageCompareReporter
{
public:
RiaImageCompareReporter();
virtual ~RiaImageCompareReporter();
void addImageDirectoryComparisonSet(const std::string& title, const std::string& baseImageDir, const std::string& newImagesDir, const std::string& diffImagesDir );
void generateHTMLReport(const std::string& filenName);
private:
static std::vector<std::string> getPngFilesInDirectory(const std::string& searchPath);
struct DirSet
{
DirSet(const std::string& title, const std::string& baseImageDir, const std::string& newImagesDir, const std::string& diffImagesDir )
: m_title(title),
m_baseImageDir(baseImageDir),
m_newImagesDir(newImagesDir),
m_diffImagesDir(diffImagesDir)
{}
std::string m_title;
std::string m_baseImageDir;
std::string m_newImagesDir;
std::string m_diffImagesDir;
};
std::vector<DirSet> m_directorySets;
};

View File

@ -0,0 +1,150 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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;
}

View File

@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
//==================================================================================================
//
// Compare two images (currently using ImageMagick in an external process)
//
//==================================================================================================
class RiaImageFileCompare
{
public:
enum ErrorType
{
IC_NO_ERROR, // No error occurred
IC_ERROR, // An error occurred
SEVERE_ERROR // Severe error occurred, it is likely that another call to compare() will also fail
};
public:
RiaImageFileCompare(QString compareExecutable);
~RiaImageFileCompare();
bool runComparison(QString imgFileName, QString refFileName, QString diffFileName);
bool imagesEqual() const;
ErrorType error() const;
QString errorMessage() const;
QString errorDetails() const;
private:
void reset();
private:
QString m_compareExecutable; // The executable for the ImageMagick compare tool
bool m_imagesEqual; // Result of last comparison
ErrorType m_lastError; // Error for last execution
QString m_errorMsg;
QString m_errorDetails;
};

View File

@ -23,86 +23,6 @@ include_directories(
)
#-----------------------------------------------------------------
# Configuration of ERT depdendence
#-----------------------------------------------------------------
# By default the ERT_ROOT_PATH variable will point to the ERT distribution which
# is embedded in the ThirdParty/ directory, but by using the ERT_ROOT_PATH
# variable you can point to a different ERT distribution.
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(ERT_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if (CMAKE_CL_64)
set(ERT_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert-windows-x64")
else()
set(ERT_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert-windows")
endif()
endif()
# The ERT binary distribution consists of four libraries, libwell, libecl,
# libutil and libgeometry and their accompanying header files. There has been a
# bit of mess of how this has been organized; either it has been on per
# directory basis as:
#
# ${ERT_ROOT_PATH}/ecl/lib/libecl.so
# ${ERT_ROOT_PATH}/ecl/include/ecl_xxx.h
#
# ${ERT_ROOT_PATH}/well/lib/libwell.so
# ${ERT_ROOT_PATH}/well/include/well_xxx.h
# ....
#
# Or alternatively everything has been in common include/ and lib/ directories.
#
# ${ERT_ROOT_PATH}/lib
# ${ERT_ROOT_PATH}/include
#
# This is indirectly goverened by the ERT_XXX_PREFIX variables. If these are
# set to blank if everything will be collected from common include/ and lib/
# dierectories.
set( ERT_ECL_PREFIX "ecl" CACHE STRING "Prefix path to use for ecl code in ert")
set( ERT_UTIL_PREFIX "util" CACHE STRING "Prefix path to use for util code in ert")
set( ERT_WELL_PREFIX "well" CACHE STRING "Prefix path to use for well code in ert")
set( ERT_GEO_PREFIX "geometry" CACHE STRING "Prefix path to use for geometry code in ert")
mark_as_advanced( ERT_UTIL_PREFIX ERT_ECL_PREFIX ERT_WELL_PREFIX ERT_GEO_PREFIX)
# Setting up include directories for ERT
set( ERT_INCLUDE_LIST
${ERT_ROOT_PATH}/include
${ERT_ROOT_PATH}/${ERT_ECL_PREFIX}/include
${ERT_ROOT_PATH}/${ERT_UTIL_PREFIX}/include
${ERT_ROOT_PATH}/${ERT_WELL_PREFIX}/include
${ERT_ROOT_PATH}/${ERT_GEO_PREFIX}/include )
# Link to these ERT libraries
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set( ERT_LIBRARY_LIST
${ERT_ROOT_PATH}/lib/libecl.a
${ERT_ROOT_PATH}/lib/libert_util.a
${ERT_ROOT_PATH}/lib/libgeometry.a
${ERT_ROOT_PATH}/lib/libwell.a )
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set( ERT_LIBRARY_LIST
${ERT_ROOT_PATH}/lib/ecl.lib
${ERT_ROOT_PATH}/lib/ert_util.lib
${ERT_ROOT_PATH}/lib/geometry.lib
${ERT_ROOT_PATH}/lib/well.lib )
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
list(APPEND ERT_LIBRARY_LIST lapack z)
endif()
include_directories( ${ERT_INCLUDE_LIST} )
# Ert configuration complete
#-----------------------------------------------------------------
# Use all cpp and h files in the subdirectories
file( GLOB_RECURSE HEADER_FILES *.h )
@ -114,6 +34,8 @@ list( APPEND CPP_SOURCES
list( APPEND CPP_SOURCES
Application/RIApplication.cpp
Application/RIPreferences.cpp
Application/RiaImageFileCompare.cpp
Application/RiaImageCompareReporter.cpp
)
list( APPEND CPP_SOURCES
@ -180,6 +102,7 @@ list( APPEND CPP_SOURCES
ReservoirDataModel/RigReservoir.cpp
ReservoirDataModel/RigReservoirBuilderMock.cpp
ReservoirDataModel/RigWellResults.cpp
ReservoirDataModel/RigGridScalarDataAccess.cpp
)
list( APPEND CPP_SOURCES
@ -234,10 +157,14 @@ qt4_add_resources( QRC_FILES_CPP ${QRC_FILES} )
set( RAW_SOURCES ${CPP_SOURCES} )
list( REMOVE_ITEM RAW_SOURCES RIStdInclude.cpp)
list( REMOVE_ITEM RAW_SOURCES ReservoirDataModel/RigReaderInterfaceECL.cpp)
list( REMOVE_ITEM RAW_SOURCES ReservoirDataModel/RigGridScalarDataAccess.cpp)
list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivCellEdgeEffectGenerator.cpp)
list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivPipeGeometryGenerator.cpp)
list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivWellPipesPartMgr.cpp)
list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivWellHeadPartMgr.cpp)
list( REMOVE_ITEM RAW_SOURCES Application/RiaImageFileCompare.cpp)
list( REMOVE_ITEM RAW_SOURCES Application/RiaImageCompareReporter.cpp)
list( REMOVE_ITEM RAW_SOURCES
@ -295,6 +222,12 @@ set( LINK_LIBRARIES
LibRender
LibGeometry
LibCore
ecl
ert_util
ert_geometry
ecl_well
${OPENGL_LIBRARIES}
${QT_LIBRARIES}
)
@ -322,23 +255,6 @@ if (MSVC)
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
endforeach( qtlib )
# DLLs ERT depends on
# add_custom_command(TARGET ResInsight POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy_directory
# "${PROJECT_SOURCE_DIR}/../ThirdParty/Ert-windows/bin/"
# ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
# ERT DLLs
# set (ERT_MODULES ecl geometry util well)
# foreach (ert_module ${ERT_MODULES})
# add_custom_command(TARGET ResInsight POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
# "${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert-windows/${ert_module}/lib/lib${ert_module}.dll"
# ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
# endforeach()
endif(MSVC)
#############################################################################
@ -381,28 +297,3 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resinsight DESTINATION ${RESINSIGHT_FINAL_NAME} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
endif()
IF(${CMAKE_SYSTEM_NAME} MATCHES "No_Linux")
install(CODE "
set (INSTALLFILE_LIST
${CMAKE_CURRENT_BINARY_DIR}/ResInsight
${CMAKE_CURRENT_SOURCE_DIR}/Adm/LicenseInformation.txt
${CMAKE_CURRENT_SOURCE_DIR}/Adm/gplLicense.txt
${QT_LIBRARY_DIR}/libQtCore.so.4
${QT_LIBRARY_DIR}/libQtGui.so.4
${QT_LIBRARY_DIR}/libQtOpenGL.so.4
/usr/lib64/libgfortran.so.1
/usr/lib64/liblapack.so.3
/usr/lib64/libblas.so.3
)
execute_process(COMMAND rm -r ${CMAKE_BINARY_DIR}/Install/ResInsight )
execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/Install/ResInsight )
foreach (installFile \${INSTALLFILE_LIST})
execute_process(COMMAND cp -v \${installFile} ${CMAKE_BINARY_DIR}/Install/ResInsight)
endforeach (installFile)
execute_process(COMMAND bash -c \"cd ${CMAKE_BINARY_DIR}/Install/ ; tar cvzf ResInsight_${STRPRODUCTVER}-bin.tar.gz ResInsight/*\" )
")
endif()

View File

@ -3,16 +3,12 @@ cmake_minimum_required (VERSION 2.8)
SET (ProjectName FileInterface_UnitTests)
project ( ${ProjectName} )
# Qt
find_package (Qt4 COMPONENTS QtCore QtGui QtMain QtOpenGl REQUIRED)
include (${QT_USE_FILE})
include_directories(
${LibCore_SOURCE_DIR}
${LibGeometry_SOURCE_DIR}
${LibRender_SOURCE_DIR}
${LibViewing_SOURCE_DIR}
${ResInsight_SOURCE_DIR}/ApplicationCode
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel
${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface
@ -24,50 +20,6 @@ include_directories(
${ResInsight_SOURCE_DIR}/CommonCode
)
#-----------------------------------------------------------------
# Ert configuration
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(ERT_ROOT_PATH "${ResInsight_SOURCE_DIR}/ThirdParty/Ert")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if (CMAKE_CL_64)
set(ERT_ROOT_PATH "${ResInsight_SOURCE_DIR}/ThirdParty/Ert-windows-x64")
else()
set(ERT_ROOT_PATH "${ResInsight_SOURCE_DIR}/ThirdParty/Ert-windows")
endif()
endif()
set( ERT_ECL_PREFIX "ecl" CACHE STRING "Prefix path to use for ecl code in ert")
set( ERT_UTIL_PREFIX "util" CACHE STRING "Prefix path to use for util code in ert")
set( ERT_WELL_PREFIX "well" CACHE STRING "Prefix path to use for well code in ert")
set( ERT_INCLUDE_LIST
${ERT_ROOT_PATH}/include
${ERT_ROOT_PATH}/${ERT_ECL_PREFIX}/include
${ERT_ROOT_PATH}/${ERT_UTIL_PREFIX}/include
${ERT_ROOT_PATH}/${ERT_WELL_PREFIX}/include )
# Link to these ERT libraries
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set( ERT_LIBRARY_LIST
${ERT_ROOT_PATH}/lib/libecl.a
${ERT_ROOT_PATH}/lib/libert_util.a
${ERT_ROOT_PATH}/lib/libgeometry.a
${ERT_ROOT_PATH}/lib/libwell.a )
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set( ERT_LIBRARY_LIST
${ERT_ROOT_PATH}/lib/ecl.lib
${ERT_ROOT_PATH}/lib/ert_util.lib
${ERT_ROOT_PATH}/lib/geometry.lib
${ERT_ROOT_PATH}/lib/well.lib )
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
list(APPEND ERT_LIBRARY_LIST lapack z)
endif()
#-----------------------------------------------------------------
include_directories( ${ERT_INCLUDE_LIST} )
set( FILEINTERFACE_CPP_SOURCES
../RifEclipseInputFileTools.cpp
../RifEclipseOutputFileTools.cpp
@ -88,6 +40,7 @@ set( RESERVOIRDATAMODEL_CPP_SOURCES
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigWellResults.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp
${ResInsight_SOURCE_DIR}/cafUserInterface/cafProgressInfo.cpp
)
@ -114,6 +67,11 @@ set( LINK_LIBRARIES
LibGeometry
LibCore
ecl
ert_util
ert_geometry
ecl_well
${QT_LIBRARIES}
)

View File

@ -16,7 +16,6 @@
//
/////////////////////////////////////////////////////////////////////////////////
#ifdef USE_ECL_LIB
#include <time.h>
@ -102,7 +101,6 @@ TEST(RigReservoirTest, WellTestErt)
well_info_free( well_info );
}
#endif
//--------------------------------------------------------------------------------------------------
/// This file contains test code taken from the test cases in ERT source code.
// There is a typedef issue (center) between ERT and QTextStream, so this file does not include any
@ -115,7 +113,7 @@ TEST(RigReservoirTest, ElipseInputGridFile)
bool result = inputReader.open("TEST10K_FLT_LGR_NNC.grdecl", &res);
EXPECT_TRUE(result);
EXPECT_EQ(size_t(1), res.mainGrid()->cells().size());
EXPECT_EQ(size_t(1), res.mainGrid()->numActiveCells());
EXPECT_EQ(size_t(1), res.mainGrid()->globalMatrixModelActiveCellCount());
}
#endif //USE_ECL_LIB
#endif

View File

@ -24,6 +24,121 @@
#include "RigReservoir.h"
#include "RifReaderEclipseOutput.h"
#include "ecl_file.h"
#include "RifEclipseOutputFileTools.h"
#include "RigReservoirCellResults.h"
#if 0
TEST(RigReservoirTest, FileOutputToolsTest)
{
cvf::ref<RifReaderEclipseOutput> readerInterfaceEcl = new RifReaderEclipseOutput;
cvf::ref<RigReservoir> reservoir = new RigReservoir;
// QString filename("d:/Models/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.EGRID");
QString filename("d:/Models/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.UNRST");
ecl_file_type* ertFile = ecl_file_open(filename.toAscii().data());
EXPECT_TRUE(ertFile);
QStringList keywords;
std::vector<size_t> keywordDataItemCounts;
RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(ertFile, &keywords, &keywordDataItemCounts);
EXPECT_TRUE(keywords.size() == keywordDataItemCounts.size());
qDebug() << "Keyword - Number of data items";
for (int i = 0; i < keywords.size(); i++)
{
QString paddedKeyword = QString("%1").arg(keywords[i], 8);
qDebug() << paddedKeyword << " - " << keywordDataItemCounts[i];
}
ecl_file_close(ertFile);
ertFile = NULL;
}
void buildResultInfoString(RigReservoir* reservoir, RifReaderInterface::PorosityModelResultType porosityModel, RimDefines::ResultCatType resultType)
{
RigReservoirCellResults* matrixResults = reservoir->mainGrid()->results(porosityModel);
{
QStringList resultNames = matrixResults->resultNames(resultType);
for (size_t i = 0 ; i < resultNames.size(); i++)
{
std::vector<double> values;
size_t scalarResultIndex = matrixResults->findOrLoadScalarResult(resultType, resultNames[i]);
EXPECT_TRUE(scalarResultIndex != cvf::UNDEFINED_SIZE_T);
QString resultText = QString("%1").arg(resultNames[i], 8);
std::vector< std::vector<double> > & resultValues = matrixResults->cellScalarResults(scalarResultIndex);
for (size_t timeStepIdx = 0; timeStepIdx < matrixResults->timeStepCount(scalarResultIndex); timeStepIdx++)
{
size_t resultValueCount = resultValues[timeStepIdx].size();
resultText += QString(" %1").arg(resultValueCount);
}
qDebug() << resultText;
}
qDebug() << "Number of items : " << resultNames.size();
}
}
TEST(RigReservoirTest, DualPorosityTest)
{
cvf::ref<RifReaderEclipseOutput> readerInterfaceEcl = new RifReaderEclipseOutput;
cvf::ref<RigReservoir> reservoir = new RigReservoir;
QString filename("d:/Models/Statoil/DualProperty/DUALPORO.EGRID");
//QString filename("d:/Models/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.EGRID");
bool result = readerInterfaceEcl->open(filename, reservoir.p());
EXPECT_TRUE(result);
qDebug() << "\n\n" <<
"Matrix porosities, DYNAMIC results" <<
"----------------------------------";
buildResultInfoString(reservoir.p(), RifReaderInterface::MATRIX_RESULTS, RimDefines::DYNAMIC_NATIVE);
qDebug() << "\n\n" <<
"Matrix porosities, STATIC results" <<
"----------------------------------";
buildResultInfoString(reservoir.p(), RifReaderInterface::MATRIX_RESULTS, RimDefines::STATIC_NATIVE);
qDebug() << "\n\n" <<
"Fracture porosities, DYNAMIC results" <<
"----------------------------------";
buildResultInfoString(reservoir.p(), RifReaderInterface::FRACTURE_RESULTS, RimDefines::DYNAMIC_NATIVE);
qDebug() << "\n\n" <<
"Fracture porosities, STATIC results" <<
"----------------------------------";
buildResultInfoString(reservoir.p(), RifReaderInterface::FRACTURE_RESULTS, RimDefines::STATIC_NATIVE);
}
//#include "RifEclipseUnifiedRestartFileAccess.h"
/*
@ -69,7 +184,6 @@ TEST(RigReservoirTest, UnifiedTestFile)
}
*/
#if 0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -149,4 +263,7 @@ TEST(RigReservoirTest, WellTest)
EXPECT_TRUE(mainGridWellCells->size() == reservoir->mainGrid()->cellCount());
}
#endif

View File

@ -31,12 +31,11 @@
#include <QTextStream>
#include <QDebug>
#ifdef USE_ECL_LIB
#include "ecl_grid.h"
#include "well_state.h"
#include "util.h"
#endif
#include <fstream>
#include "RigGridScalarDataAccess.h"
@ -213,11 +212,11 @@ std::map<QString, QString> RifEclipseInputFileTools::readProperties(const QStri
ecl_kw_type* eclKeyWordData = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_FLOAT_TYPE);
if (eclKeyWordData)
{
QString newResultName = reservoir->mainGrid()->results()->makeResultNameUnique(fileKeywords[i].keyword);
QString newResultName = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(fileKeywords[i].keyword);
size_t resultIndex = reservoir->mainGrid()->results()->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); // Should really merge with inputProperty object information because we need to use PropertyName, and not keyword
size_t resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); // Should really merge with inputProperty object information because we need to use PropertyName, and not keyword
std::vector< std::vector<double> >& newPropertyData = reservoir->mainGrid()->results()->cellScalarResults(resultIndex);
std::vector< std::vector<double> >& newPropertyData = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
newPropertyData.push_back(std::vector<double>());
newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL);
ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data());
@ -295,13 +294,13 @@ bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigReservoi
if (eclKeyWordData)
{
QString newResultName = resultName;
size_t resultIndex = reservoir->mainGrid()->results()->findScalarResultIndex(newResultName);
size_t resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
{
resultIndex = reservoir->mainGrid()->results()->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName);
resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName);
}
std::vector< std::vector<double> >& newPropertyData = reservoir->mainGrid()->results()->cellScalarResults(resultIndex);
std::vector< std::vector<double> >& newPropertyData = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
newPropertyData.resize(1);
newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL);
ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data());
@ -375,7 +374,7 @@ bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName,
{
CVF_ASSERT(reservoir);
size_t resultIndex = reservoir->mainGrid()->results()->findScalarResultIndex(resultName);
size_t resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
{
return false;
@ -387,7 +386,7 @@ bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName,
return false;
}
std::vector< std::vector<double> >& resultData = reservoir->mainGrid()->results()->cellScalarResults(resultIndex);
std::vector< std::vector<double> >& resultData = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
if (resultData.size() == 0)
{
return false;
@ -403,11 +402,11 @@ bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName,
/// Create and write a result vector with values for all cells.
/// undefinedValue is used for cells with no result
//--------------------------------------------------------------------------------------------------
bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileName, RigReservoir* reservoir, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue)
bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileName, RigReservoir* reservoir, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue)
{
CVF_ASSERT(reservoir);
size_t resultIndex = reservoir->mainGrid()->results()->findScalarResultIndex(resultName);
size_t resultIndex = reservoir->mainGrid()->results(porosityModel)->findScalarResultIndex(resultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
{
return false;
@ -419,16 +418,21 @@ bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileNa
return false;
}
cvf::ref<RigGridScalarDataAccess> dataAccessObject = reservoir->mainGrid()->dataAccessObject(porosityModel, timeStep, resultIndex);
if (dataAccessObject.isNull())
{
return false;
}
std::vector<double> resultData;
size_t i, j, k;
for (k = 0; k < reservoir->mainGrid()->cellCountK(); k++)
{
for (j = 0; j < reservoir->mainGrid()->cellCountJ(); j++)
{
for (i = 0; i < reservoir->mainGrid()->cellCountI(); i++)
{
double resultValue = reservoir->mainGrid()->cellScalar(timeStep, resultIndex, i, j, k);
double resultValue = dataAccessObject->cellScalar(i, j, k);
if (resultValue == HUGE_VAL)
{
resultValue = undefinedValue;
@ -455,7 +459,7 @@ void RifEclipseInputFileTools::writeDataToTextFile(QFile* file, const QString& e
out << eclipseKeyWord << "\n" << right << qSetFieldWidth(16);
caf::ProgressInfo pi(resultData.size(), QString("Writing data to file %1").arg(file->fileName()) );
int progressSteps = resultData.size() / 20;
size_t progressSteps = resultData.size() / 20;
size_t i;
for (i = 0; i < resultData.size(); i++)
@ -528,13 +532,13 @@ bool RifEclipseInputFileTools::readPropertyAtFilePosition(const QString& fileNam
if (eclKeyWordData)
{
QString newResultName = resultName;
size_t resultIndex = reservoir->mainGrid()->results()->findScalarResultIndex(newResultName);
size_t resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
{
resultIndex = reservoir->mainGrid()->results()->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName);
resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName);
}
std::vector< std::vector<double> >& newPropertyData = reservoir->mainGrid()->results()->cellScalarResults(resultIndex);
std::vector< std::vector<double> >& newPropertyData = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
newPropertyData.resize(1);
newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL);
ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data());

View File

@ -24,6 +24,7 @@
#include <map>
#include <QString>
#include "RifReaderInterface.h"
class RigReservoir;
@ -63,7 +64,7 @@ public:
static const std::vector<QString>& knownPropertyKeywords();
static bool writePropertyToTextFile(const QString& fileName, RigReservoir* reservoir, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord);
static bool writeBinaryResultToTextFile(const QString& fileName, RigReservoir* reservoir, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue);
static bool writeBinaryResultToTextFile(const QString& fileName, RigReservoir* reservoir, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue);
private:
static void writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector<double>& resultData);

View File

@ -18,23 +18,21 @@
#include "RifEclipseOutputFileTools.h"
#ifdef USE_ECL_LIB
#include "util.h"
#include "ecl_file.h"
#include "ecl_intehead.h"
#endif //USE_ECL_LIB
#include "ecl_kw_magic.h"
#include <QFileInfo>
#include <QDebug>
#include "cafProgressInfo.h"
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
RifEclipseOutputFileTools::RifEclipseOutputFileTools()
{
#ifdef USE_ECL_LIB
m_file = NULL;
#endif //USE_ECL_LIB
}
@ -43,207 +41,101 @@ RifEclipseOutputFileTools::RifEclipseOutputFileTools()
//--------------------------------------------------------------------------------------------------
RifEclipseOutputFileTools::~RifEclipseOutputFileTools()
{
close();
}
//--------------------------------------------------------------------------------------------------
/// Open file given by name
//--------------------------------------------------------------------------------------------------
bool RifEclipseOutputFileTools::open(const QString& fileName)
{
#ifdef USE_ECL_LIB
// Close current file if any
close();
m_file = ecl_file_open(fileName.toAscii().data());
if (!m_file) return false;
return true;
#else
return false;
#endif //USE_ECL_LIB
}
//--------------------------------------------------------------------------------------------------
/// Close file
//--------------------------------------------------------------------------------------------------
void RifEclipseOutputFileTools::close()
{
#ifdef USE_ECL_LIB
if (m_file)
{
ecl_file_close(m_file);
m_file = NULL;
}
#endif //USE_ECL_LIB
}
//--------------------------------------------------------------------------------------------------
/// Get the number of occurrences of the given keyword
//--------------------------------------------------------------------------------------------------
size_t RifEclipseOutputFileTools::numOccurrences(const QString& keyword)
{
#ifdef USE_ECL_LIB
CVF_ASSERT(m_file);
return (size_t) ecl_file_get_num_named_kw(m_file, keyword.toAscii().data());
#else
return 0;
#endif //USE_ECL_LIB
}
//--------------------------------------------------------------------------------------------------
/// Get keywords found on file given by name.
/// If numDataItems > -1, get keywords with that exact number of data items only.
//--------------------------------------------------------------------------------------------------
bool RifEclipseOutputFileTools::keywordsOnFile(QStringList* keywords, size_t numDataItems, size_t numSteps)
{
#ifdef USE_ECL_LIB
CVF_ASSERT(m_file);
CVF_ASSERT(keywords);
keywords->clear();
size_t numKeywords = ecl_file_get_num_distinct_kw(m_file);
caf::ProgressInfo info(numKeywords, "Reading Keywords on file");
size_t i;
for (i = 0; i < numKeywords; i++)
{
const char* kw = ecl_file_iget_distinct_kw(m_file , i);
size_t numKWOccurences = ecl_file_get_num_named_kw(m_file, kw);
if (numDataItems != cvf::UNDEFINED_SIZE_T)
{
bool dataTypeSupported = true;
size_t numKWValues = 0;
size_t j;
for (j = 0; j < numKWOccurences; j++)
{
numKWValues += (size_t) ecl_file_iget_named_size(m_file, kw, j);
// Check the data type - only float and double are supported
ecl_type_enum dataType = ecl_file_iget_named_type(m_file, kw, j);
if (dataType != ECL_DOUBLE_TYPE && dataType != ECL_FLOAT_TYPE && dataType != ECL_INT_TYPE )
{
dataTypeSupported = false;
break;
}
}
if (dataTypeSupported)
{
if (numSteps != cvf::UNDEFINED_SIZE_T && numSteps > 0)
{
numKWValues /= numSteps;
}
// Append keyword to the list if it has the given number of values in total
if (numKWValues == numDataItems)
{
keywords->append(QString(kw));
}
}
}
else
{
keywords->append(QString(kw));
}
info.setProgress(i);
}
return true;
#else
return false;
#endif //USE_ECL_LIB
}
//--------------------------------------------------------------------------------------------------
/// Get list of time step texts (dates)
//--------------------------------------------------------------------------------------------------
bool RifEclipseOutputFileTools::timeStepsText(QStringList* timeSteps)
{
#ifdef USE_ECL_LIB
CVF_ASSERT(timeSteps);
CVF_ASSERT(m_file);
const char* KW_INTEHEAD = "INTEHEAD";
// Get the number of occurrences of the INTEHEAD keyword
size_t numINTEHEAD = numOccurrences(KW_INTEHEAD);
QStringList timeStepsFound;
size_t i;
for (i = 0; i < numINTEHEAD; i++)
{
ecl_kw_type* kwINTEHEAD = ecl_file_iget_named_kw(m_file, KW_INTEHEAD, i);
if (kwINTEHEAD)
{
// Get date info
time_t stepTime = ecl_intehead_date(kwINTEHEAD);
// Hack!!! We seem to get 01/01/1970 (time -1) for sub grids!
if (stepTime < 0) continue;
// Build date string
char* dateString = util_alloc_date_string(stepTime);
timeStepsFound += QString(dateString);
util_safe_free(dateString);
}
}
// Time steps are given for both the main grid and all sub grids,
// so we need to make sure that duplicates are removed
timeStepsFound.removeDuplicates();
// Return time step info to caller
*timeSteps = timeStepsFound;
return true;
#else
return false;
#endif //USE_ECL_LIB
}
//--------------------------------------------------------------------------------------------------
/// Get list of time step texts (dates)
//--------------------------------------------------------------------------------------------------
bool RifEclipseOutputFileTools::timeSteps(QList<QDateTime>* timeSteps)
void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, QList<QDateTime>* timeSteps, bool* detectedFractionOfDay )
{
#ifdef USE_ECL_LIB
CVF_ASSERT(timeSteps);
CVF_ASSERT(m_file);
const char* KW_INTEHEAD = "INTEHEAD";
CVF_ASSERT(ecl_file);
// Get the number of occurrences of the INTEHEAD keyword
size_t numINTEHEAD = numOccurrences(KW_INTEHEAD);
int numINTEHEAD = ecl_file_get_num_named_kw(ecl_file, INTEHEAD_KW);
// Get the number of occurrences of the DOUBHEAD keyword
int numDOUBHEAD = ecl_file_get_num_named_kw(ecl_file, DOUBHEAD_KW);
CVF_ASSERT(numINTEHEAD == numDOUBHEAD);
bool hasFractionOfDay = false;
bool foundAllDayValues = false;
const double delta = 0.001;
// Find all days, and stop when the double value is lower than the previous
QList<double> days;
for (int i = 0; i < numDOUBHEAD; i++)
{
if (foundAllDayValues) continue;;
ecl_kw_type* kwDOUBHEAD = ecl_file_iget_named_kw(ecl_file, DOUBHEAD_KW, i);
if (kwDOUBHEAD)
{
double dayValue = ecl_kw_iget_double(kwDOUBHEAD, DOUBHEAD_DAYS_INDEX);
double floorDayValue = cvf::Math::floor(dayValue);
if (dayValue - floorDayValue > delta)
{
hasFractionOfDay = true;
}
days.push_back(dayValue);
}
}
QList<QDateTime> timeStepsFound;
size_t i;
for (i = 0; i < numINTEHEAD; i++)
if (hasFractionOfDay)
{
ecl_kw_type* kwINTEHEAD = ecl_file_iget_named_kw(m_file, KW_INTEHEAD, i);
ecl_kw_type* kwINTEHEAD = ecl_file_iget_named_kw(ecl_file, INTEHEAD_KW, 0);
if (kwINTEHEAD)
{
// Get date info
time_t stepTime = ecl_intehead_date(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);
// Hack!!! We seem to get 01/01/1970 (time -1) for sub grids!
if (stepTime < 0) continue;
// Build date string
QDateTime dateTime = QDateTime::fromTime_t(stepTime);
if (timeStepsFound.indexOf(dateTime) < 0)
for (int i = 0; i < days.size(); i++)
{
timeStepsFound.push_back(dateTime);
double dayValue = days[i];
double floorDayValue = cvf::Math::floor(dayValue);
double dayFraction = dayValue - floorDayValue;
int seconds = (dayFraction * 24.0 * 60.0 * 60.0);
QTime time(0, 0);
time = time.addSecs(seconds);
QDate reportDate = simulationStart;
reportDate = reportDate.addDays(floorDayValue);
QDateTime reportDateTime(reportDate, time);
if (timeStepsFound.indexOf(reportDateTime) < 0)
{
timeStepsFound.push_back(reportDateTime);
}
}
}
}
else
{
for (int i = 0; i < numINTEHEAD; i++)
{
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);
QDate reportDate(year, month, day);
CVF_ASSERT(reportDate.isValid());
QDateTime reportDateTime(reportDate);
if (timeStepsFound.indexOf(reportDateTime) < 0)
{
timeStepsFound.push_back(reportDateTime);
}
}
}
}
@ -251,22 +143,19 @@ bool RifEclipseOutputFileTools::timeSteps(QList<QDateTime>* timeSteps)
// Return time step info to caller
*timeSteps = timeStepsFound;
return true;
#else
return false;
#endif //USE_ECL_LIB
if (detectedFractionOfDay)
{
*detectedFractionOfDay = hasFractionOfDay;
}
}
//--------------------------------------------------------------------------------------------------
/// Get first occurrence of file of given type in given list of filenames, as filename or NULL if not found
//--------------------------------------------------------------------------------------------------
bool RifEclipseOutputFileTools::keywordData(const QString& keyword, size_t index, std::vector<double>* values)
{
#ifdef USE_ECL_LIB
CVF_ASSERT(m_file);
CVF_ASSERT(values);
ecl_kw_type* kwData = ecl_file_iget_named_kw(m_file, keyword.toAscii().data(), index);
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifEclipseOutputFileTools::keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector<double>* values)
{
ecl_kw_type* kwData = ecl_file_iget_named_kw(ecl_file, keyword.toAscii().data(), static_cast<int>(fileKeywordOccurrence));
if (kwData)
{
size_t numValues = ecl_kw_get_size(kwData);
@ -276,19 +165,17 @@ bool RifEclipseOutputFileTools::keywordData(const QString& keyword, size_t index
ecl_kw_get_data_as_double(kwData, doubleData.data());
values->insert(values->end(), doubleData.begin(), doubleData.end());
return true;
}
return true;
#else
return false;
#endif //USE_ECL_LIB
}
//--------------------------------------------------------------------------------------------------
/// Get first occurrence of file of given type in given list of filenames, as filename or NULL if not found
//--------------------------------------------------------------------------------------------------
#ifdef USE_ECL_LIB
QString RifEclipseOutputFileTools::fileNameByType(const QStringList& fileSet, ecl_file_enum fileType)
{
int i;
@ -304,13 +191,11 @@ QString RifEclipseOutputFileTools::fileNameByType(const QStringList& fileSet, ec
return QString::null;
}
#endif //USE_ECL_LIB
//--------------------------------------------------------------------------------------------------
/// Get all files of file of given type in given list of filenames, as filename or NULL if not found
//--------------------------------------------------------------------------------------------------
#ifdef USE_ECL_LIB
QStringList RifEclipseOutputFileTools::fileNamesByType(const QStringList& fileSet, ecl_file_enum fileType)
{
QStringList fileNames;
@ -328,7 +213,6 @@ QStringList RifEclipseOutputFileTools::fileNamesByType(const QStringList& fileSe
return fileNames;
}
#endif //USE_ECL_LIB
//--------------------------------------------------------------------------------------------------
@ -339,7 +223,6 @@ bool RifEclipseOutputFileTools::fileSet(const QString& fileName, QStringList* fi
CVF_ASSERT(fileSet);
fileSet->clear();
#ifdef USE_ECL_LIB
QString filePath = QFileInfo(fileName).absoluteFilePath();
filePath = QFileInfo(filePath).path();
QString fileNameBase = QFileInfo(fileName).baseName();
@ -354,17 +237,46 @@ bool RifEclipseOutputFileTools::fileSet(const QString& fileName, QStringList* fi
}
stringlist_free(eclipseFiles);
#endif //USE_ECL_LIB
return fileSet->count() > 0;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
#ifdef USE_ECL_LIB
ecl_file_type* RifEclipseOutputFileTools::filePointer()
void RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(ecl_file_type* ecl_file, QStringList* keywords, std::vector<size_t>* keywordDataItemCounts)
{
return m_file;
if (!ecl_file || !keywords || !keywordDataItemCounts) return;
int numKeywords = ecl_file_get_num_distinct_kw(ecl_file);
caf::ProgressInfo info(numKeywords, "Reading Keywords on file");
for (int i = 0; i < numKeywords; i++)
{
const char* kw = ecl_file_iget_distinct_kw(ecl_file , i);
int numKeywordOccurrences = ecl_file_get_num_named_kw(ecl_file, kw);
bool validData = true;
size_t fileResultValueCount = 0;
for (int j = 0; j < numKeywordOccurrences; j++)
{
fileResultValueCount += ecl_file_iget_named_size(ecl_file, kw, j);
ecl_type_enum dataType = ecl_file_iget_named_type(ecl_file, kw, j);
if (dataType != ECL_DOUBLE_TYPE && dataType != ECL_FLOAT_TYPE && dataType != ECL_INT_TYPE )
{
validData = false;
break;
}
}
if (validData)
{
keywords->append(QString(kw));
keywordDataItemCounts->push_back(fileResultValueCount);
}
info.setProgress(i);
}
}
#endif //USE_ECL_LIB

View File

@ -25,47 +25,32 @@
#include <QString>
#include <QStringList>
#include <QDateTime>
#include "RifReaderInterface.h"
#include "ecl_util.h"
typedef struct ecl_file_struct ecl_file_type;
#ifdef USE_ECL_LIB
#include "ecl_file.h"
#endif //USE_ECL_LIB
//==================================================================================================
//
// Class for access to Eclipse "keyword" files using libecl
//
//
//==================================================================================================
class RifEclipseOutputFileTools : public cvf::Object
class RifEclipseOutputFileTools
{
public:
RifEclipseOutputFileTools();
virtual ~RifEclipseOutputFileTools();
bool open(const QString& fileName);
void close();
static void findKeywordsAndDataItemCounts(ecl_file_type* ecl_file, QStringList* keywords, std::vector<size_t>* keywordDataItemCounts);
static bool keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector<double>* values);
size_t numOccurrences(const QString& keyword);
bool keywordsOnFile(QStringList* keywords, size_t numDataItems = cvf::UNDEFINED_SIZE_T, size_t numSteps = cvf::UNDEFINED_SIZE_T);
// static void timeStepsText(ecl_file_type* ecl_file, QStringList* timeSteps);
static void timeSteps(ecl_file_type* ecl_file, QList<QDateTime>* timeSteps, bool* detectedFractionOfDay = NULL);
bool timeStepsText(QStringList* timeSteps);
bool timeSteps(QList<QDateTime>* timeSteps);
bool keywordData(const QString& keyword, size_t index, std::vector<double>* values);
#ifdef USE_ECL_LIB
ecl_file_type* filePointer();
#endif //USE_ECL_LIB
// Static methods
static bool fileSet(const QString& fileName, QStringList* fileSet);
#ifdef USE_ECL_LIB
static QString fileNameByType(const QStringList& fileSet, ecl_file_enum fileType);
static QStringList fileNamesByType(const QStringList& fileSet, ecl_file_enum fileType);
#endif //USE_ECL_LIB
protected:
#ifdef USE_ECL_LIB
ecl_file_type* m_file;
#endif //USE_ECL_LIB
};

View File

@ -22,10 +22,8 @@
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
RifEclipseRestartDataAccess::RifEclipseRestartDataAccess(size_t numGrids, size_t numActiveCells)
RifEclipseRestartDataAccess::RifEclipseRestartDataAccess()
{
m_numGrids = numGrids;
m_numActiveCells = numActiveCells;
}

View File

@ -27,9 +27,9 @@
#include <vector>
#ifdef USE_ECL_LIB
#include "well_info.h"
#endif // USE_ECL_LIB
#include "RifReaderInterface.h"
//==================================================================================================
//
@ -39,25 +39,17 @@
class RifEclipseRestartDataAccess : public cvf::Object
{
public:
RifEclipseRestartDataAccess(size_t numGrids, size_t numActiveCells);
RifEclipseRestartDataAccess();
virtual ~RifEclipseRestartDataAccess();
virtual bool open(const QStringList& fileSet) = 0;
virtual void close() = 0;
virtual size_t numTimeSteps() = 0;
virtual QStringList timeStepsText() = 0;
virtual size_t timeStepCount() = 0;
virtual QList<QDateTime> timeSteps() = 0;
virtual QStringList resultNames() = 0;
virtual bool results(const QString& resultName, size_t timeStep, std::vector<double>* values) = 0;
virtual void resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts) = 0;
virtual bool results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector<double>* values) = 0;
#ifdef USE_ECL_LIB
virtual void readWellData(well_info_type * well_info) = 0;
#endif
protected:
size_t m_numGrids;
size_t m_numActiveCells;
};

View File

@ -18,13 +18,14 @@
#include "RifEclipseRestartFilesetAccess.h"
#include "RifEclipseOutputFileTools.h"
#include "cafProgressInfo.h"
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
RifEclipseRestartFilesetAccess::RifEclipseRestartFilesetAccess(size_t numGrids, size_t numActiveCells)
: RifEclipseRestartDataAccess(numGrids, numActiveCells)
RifEclipseRestartFilesetAccess::RifEclipseRestartFilesetAccess()
: RifEclipseRestartDataAccess()
{
}
@ -43,18 +44,21 @@ bool RifEclipseRestartFilesetAccess::open(const QStringList& fileSet)
{
close();
size_t numFiles = fileSet.size();
size_t i;
int numFiles = fileSet.size();
caf::ProgressInfo progInfo(numFiles,"");
int i;
for (i = 0; i < numFiles; i++)
{
cvf::ref<RifEclipseOutputFileTools> fileAccess = new RifEclipseOutputFileTools;
if (!fileAccess->open(fileSet[i]))
{
close();
return false;
}
progInfo.setProgressDescription(fileSet[i]);
m_files.push_back(fileAccess);
ecl_file_type* ecl_file = ecl_file_open(fileSet[i].toAscii().data());
if (!ecl_file) return false;
m_ecl_files.push_back(ecl_file);
progInfo.incrementProgress();
}
return true;
@ -65,34 +69,20 @@ bool RifEclipseRestartFilesetAccess::open(const QStringList& fileSet)
//--------------------------------------------------------------------------------------------------
void RifEclipseRestartFilesetAccess::close()
{
m_files.clear();
for (size_t i = 0; i < m_ecl_files.size(); i++)
{
ecl_file_close(m_ecl_files[i]);
}
m_ecl_files.clear();
}
//--------------------------------------------------------------------------------------------------
/// Get the number of time steps
//--------------------------------------------------------------------------------------------------
size_t RifEclipseRestartFilesetAccess::numTimeSteps()
size_t RifEclipseRestartFilesetAccess::timeStepCount()
{
return m_files.size();
}
//--------------------------------------------------------------------------------------------------
/// Get the time step texts
//--------------------------------------------------------------------------------------------------
QStringList RifEclipseRestartFilesetAccess::timeStepsText()
{
QStringList timeSteps;
size_t numSteps = numTimeSteps();
size_t i;
for (i = 0; i < numSteps; i++)
{
QStringList stepText;
m_files[i]->timeStepsText(&stepText);
timeSteps.append(stepText.size() == 1 ? stepText : QStringList(QString("Step %1").arg(i+1)));
}
return timeSteps;
return m_ecl_files.size();
}
//--------------------------------------------------------------------------------------------------
@ -102,12 +92,13 @@ QList<QDateTime> RifEclipseRestartFilesetAccess::timeSteps()
{
QList<QDateTime> timeSteps;
size_t numSteps = numTimeSteps();
size_t numSteps = timeStepCount();
size_t i;
for (i = 0; i < numSteps; i++)
{
QList<QDateTime> stepTime;
m_files[i]->timeSteps(&stepTime);
RifEclipseOutputFileTools::timeSteps(m_ecl_files[i], &stepTime);
if (stepTime.size() == 1)
{
@ -125,29 +116,31 @@ QList<QDateTime> RifEclipseRestartFilesetAccess::timeSteps()
//--------------------------------------------------------------------------------------------------
/// Get list of result names
//--------------------------------------------------------------------------------------------------
QStringList RifEclipseRestartFilesetAccess::resultNames()
void RifEclipseRestartFilesetAccess::resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts)
{
CVF_ASSERT(numTimeSteps() > 0);
CVF_ASSERT(timeStepCount() > 0);
// Get the results found on the first file
QStringList resultsList;
m_files[0]->keywordsOnFile(&resultsList, m_numActiveCells, 1);
std::vector<size_t> valueCountForOneFile;
RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(m_ecl_files[0], resultNames, &valueCountForOneFile);
return resultsList;
for (size_t i = 0; i < valueCountForOneFile.size(); i++)
{
resultDataItemCounts->push_back(valueCountForOneFile[i] * timeStepCount());
}
}
//--------------------------------------------------------------------------------------------------
/// Get result values for given time step
//--------------------------------------------------------------------------------------------------
bool RifEclipseRestartFilesetAccess::results(const QString& resultName, size_t timeStep, std::vector<double>* values)
bool RifEclipseRestartFilesetAccess::results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector<double>* values)
{
size_t numOccurrences = m_files[timeStep]->numOccurrences(resultName);
size_t numOccurrences = ecl_file_get_num_named_kw(m_ecl_files[timeStep], resultName.toAscii().data());
// No results for this result variable for current time step found
if (numOccurrences == 0) return true;
// Result handling depends on presens of result values for all grids
if (m_numGrids != numOccurrences)
// Result handling depends on presents of result values for all grids
if (gridCount != numOccurrences)
{
return false;
}
@ -156,7 +149,8 @@ bool RifEclipseRestartFilesetAccess::results(const QString& resultName, size_t t
for (i = 0; i < numOccurrences; i++)
{
std::vector<double> partValues;
if (!m_files[timeStep]->keywordData(resultName, i, &partValues)) // !! don't need to append afterwards
if (!RifEclipseOutputFileTools::keywordData(m_ecl_files[timeStep], resultName, i, &partValues))
{
return false;
}
@ -171,15 +165,17 @@ bool RifEclipseRestartFilesetAccess::results(const QString& resultName, size_t t
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
#ifdef USE_ECL_LIB
void RifEclipseRestartFilesetAccess::readWellData(well_info_type* well_info)
{
if (!well_info) return;
size_t i;
for (i=0; i < m_files.size(); i++)
for (size_t i = 0; i < m_ecl_files.size(); i++)
{
well_info_add_UNRST_wells(well_info, m_files[i]->filePointer());
const char* fileName = ecl_file_get_src_file(m_ecl_files[i]);
int reportNumber = ecl_util_filename_report_nr(fileName);
if(reportNumber != -1)
{
well_info_add_wells(well_info, m_ecl_files[i], reportNumber);
}
}
}
#endif

View File

@ -32,23 +32,20 @@ class RifEclipseOutputFileTools;
class RifEclipseRestartFilesetAccess : public RifEclipseRestartDataAccess
{
public:
RifEclipseRestartFilesetAccess(size_t numGrids, size_t numActiveCells);
RifEclipseRestartFilesetAccess();
virtual ~RifEclipseRestartFilesetAccess();
bool open(const QStringList& fileSet);
void close();
size_t numTimeSteps();
QStringList timeStepsText();
size_t timeStepCount();
QList<QDateTime> timeSteps();
QStringList resultNames();
bool results(const QString& resultName, size_t timeStep, std::vector<double>* values);
void resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts);
bool results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector<double>* values);
#ifdef USE_ECL_LIB
virtual void readWellData(well_info_type* well_info);
#endif //USE_ECL_LIB
private:
std::vector< cvf::ref<RifEclipseOutputFileTools> > m_files;
std::vector< ecl_file_type* > m_ecl_files;
};

View File

@ -19,19 +19,18 @@
#include "RifEclipseUnifiedRestartFileAccess.h"
#include "RifEclipseOutputFileTools.h"
#ifdef USE_ECL_LIB
#include <well_state.h>
#include <well_info.h>
#include <well_conn.h>
#include <well_ts.h>
#endif
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
RifEclipseUnifiedRestartFileAccess::RifEclipseUnifiedRestartFileAccess(size_t numGrids, size_t numActiveCells)
: RifEclipseRestartDataAccess(numGrids, numActiveCells)
RifEclipseUnifiedRestartFileAccess::RifEclipseUnifiedRestartFileAccess()
: RifEclipseRestartDataAccess()
{
m_ecl_file = NULL;
}
//--------------------------------------------------------------------------------------------------
@ -39,7 +38,12 @@ RifEclipseUnifiedRestartFileAccess::RifEclipseUnifiedRestartFileAccess(size_t nu
//--------------------------------------------------------------------------------------------------
RifEclipseUnifiedRestartFileAccess::~RifEclipseUnifiedRestartFileAccess()
{
close();
if (m_ecl_file)
{
ecl_file_close(m_ecl_file);
}
m_ecl_file = NULL;
}
//--------------------------------------------------------------------------------------------------
@ -47,21 +51,12 @@ RifEclipseUnifiedRestartFileAccess::~RifEclipseUnifiedRestartFileAccess()
//--------------------------------------------------------------------------------------------------
bool RifEclipseUnifiedRestartFileAccess::open(const QStringList& fileSet)
{
#ifdef USE_ECL_LIB
QString fileName = fileSet[0];
cvf::ref<RifEclipseOutputFileTools> fileAccess = new RifEclipseOutputFileTools;
if (!fileAccess->open(fileName))
{
return false;
}
m_file = fileAccess;
m_ecl_file = ecl_file_open(fileName.toAscii().data());
if (!m_ecl_file) return false;
return true;
#else
return false;
#endif
}
//--------------------------------------------------------------------------------------------------
@ -69,34 +64,14 @@ bool RifEclipseUnifiedRestartFileAccess::open(const QStringList& fileSet)
//--------------------------------------------------------------------------------------------------
void RifEclipseUnifiedRestartFileAccess::close()
{
if (m_file.notNull())
{
m_file->close();
m_file = NULL;
}
}
//--------------------------------------------------------------------------------------------------
/// Get the number of time steps
//--------------------------------------------------------------------------------------------------
size_t RifEclipseUnifiedRestartFileAccess::numTimeSteps()
size_t RifEclipseUnifiedRestartFileAccess::timeStepCount()
{
QStringList timeSteps = timeStepsText();
return timeSteps.size();
}
//--------------------------------------------------------------------------------------------------
/// Get the time step texts
//--------------------------------------------------------------------------------------------------
QStringList RifEclipseUnifiedRestartFileAccess::timeStepsText()
{
RifEclipseOutputFileTools* file = m_file.p();
CVF_ASSERT(file != NULL);
QStringList timeSteps;
file->timeStepsText(&timeSteps);
return timeSteps;
return timeSteps().size();
}
//--------------------------------------------------------------------------------------------------
@ -104,11 +79,10 @@ QStringList RifEclipseUnifiedRestartFileAccess::timeStepsText()
//--------------------------------------------------------------------------------------------------
QList<QDateTime> RifEclipseUnifiedRestartFileAccess::timeSteps()
{
RifEclipseOutputFileTools* file = m_file.p();
CVF_ASSERT(file != NULL);
CVF_ASSERT(m_ecl_file != NULL);
QList<QDateTime> timeSteps;
file->timeSteps(&timeSteps);
RifEclipseOutputFileTools::timeSteps(m_ecl_file, &timeSteps);
return timeSteps;
}
@ -116,32 +90,26 @@ QList<QDateTime> RifEclipseUnifiedRestartFileAccess::timeSteps()
//--------------------------------------------------------------------------------------------------
/// Get list of result names
//--------------------------------------------------------------------------------------------------
QStringList RifEclipseUnifiedRestartFileAccess::resultNames()
void RifEclipseUnifiedRestartFileAccess::resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts)
{
// Get the results found on the UNRST file
QStringList resultsList;
m_file->keywordsOnFile(&resultsList, m_numActiveCells, numTimeSteps());
return resultsList;
RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(m_ecl_file, resultNames, resultDataItemCounts);
}
//--------------------------------------------------------------------------------------------------
/// Get result values for given time step
//--------------------------------------------------------------------------------------------------
bool RifEclipseUnifiedRestartFileAccess::results(const QString& resultName, size_t timeStep, std::vector<double>* values)
bool RifEclipseUnifiedRestartFileAccess::results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector<double>* values)
{
size_t numOccurrences = m_file->numOccurrences(resultName);
size_t startIndex = timeStep*m_numGrids;
CVF_ASSERT(startIndex + m_numGrids <= numOccurrences);
size_t numOccurrences = ecl_file_get_num_named_kw(m_ecl_file, resultName.toAscii().data());
size_t i;
for (i = startIndex; i < startIndex + m_numGrids; i++)
size_t startIndex = timeStep * gridCount;
CVF_ASSERT(startIndex + gridCount <= numOccurrences);
size_t occurrenceIdx;
for (occurrenceIdx = startIndex; occurrenceIdx < startIndex + gridCount; occurrenceIdx++)
{
std::vector<double> partValues;
if (!m_file->keywordData(resultName, i, &partValues)) // !! don't need to append afterwards
{
return false;
}
RifEclipseOutputFileTools::keywordData(m_ecl_file, resultName, occurrenceIdx, &partValues);
values->insert(values->end(), partValues.begin(), partValues.end());
}
@ -153,12 +121,11 @@ bool RifEclipseUnifiedRestartFileAccess::results(const QString& resultName, size
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
#ifdef USE_ECL_LIB
void RifEclipseUnifiedRestartFileAccess::readWellData(well_info_type* well_info)
{
if (!well_info) return;
CVF_ASSERT(m_ecl_file);
well_info_add_UNRST_wells(well_info, m_file->filePointer());
well_info_add_UNRST_wells(well_info, m_ecl_file);
}
#endif

View File

@ -22,9 +22,9 @@
class RifEclipseOutputFileTools;
#ifdef USE_ECL_LIB
//typedef struct ecl_file_struct ecl_file_type;
#include "well_info.h"
#endif // USE_ECL_LIB
//==================================================================================================
//
@ -34,23 +34,20 @@ class RifEclipseOutputFileTools;
class RifEclipseUnifiedRestartFileAccess : public RifEclipseRestartDataAccess
{
public:
RifEclipseUnifiedRestartFileAccess(size_t numGrids, size_t numActiveCells);
RifEclipseUnifiedRestartFileAccess();
virtual ~RifEclipseUnifiedRestartFileAccess();
bool open(const QStringList& fileSet);
void close();
size_t numTimeSteps();
QStringList timeStepsText();
size_t timeStepCount();
QList<QDateTime> timeSteps();
QStringList resultNames();
bool results(const QString& resultName, size_t timeStep, std::vector<double>* values);
void resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts);
bool results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector<double>* values);
#ifdef USE_ECL_LIB
virtual void readWellData(well_info_type * well_info);
#endif
private:
cvf::ref<RifEclipseOutputFileTools> m_file;
ecl_file_type* m_ecl_file;
};

View File

@ -30,10 +30,8 @@
#include <iostream>
#include <cmath>
#ifdef USE_ECL_LIB
#include "ecl_grid.h"
#include "well_state.h"
#endif //USE_ECL_LIB
#include "util.h"
//==================================================================================================
@ -93,3 +91,4 @@ bool RifReaderEclipseInput::open(const QString& fileName, RigReservoir* reservoi
return isOk;
}

View File

@ -38,7 +38,6 @@ public:
virtual void close() {}
virtual bool staticResult(const QString& result, std::vector<double>* values) { return false; }
virtual bool dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values) { return false; }
virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values ) { return false; }
virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values ) { return false; }
};

View File

@ -26,13 +26,12 @@
#include "RifEclipseOutputFileTools.h"
#include "RifEclipseUnifiedRestartFileAccess.h"
#include "RifEclipseRestartFilesetAccess.h"
#include "RifReaderInterface.h"
#include <iostream>
#ifdef USE_ECL_LIB
#include "ecl_grid.h"
#include "well_state.h"
#endif //USE_ECL_LIB
#include "cafProgressInfo.h"
//--------------------------------------------------------------------------------------------------
@ -64,10 +63,10 @@
//
// The indexing conventions for vertices in ResInsight
//
// 7-------------6
// /| /|
// / | / |
// / | / |
// 7-------------6 |k
// /| /| | /j
// / | / | |/
// / | / | *---i
// 4-------------5 |
// | | | |
// | 3---------|---2
@ -85,8 +84,7 @@ static const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 };
// Static functions
//**************************************************************************************************
#ifdef USE_ECL_LIB
bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const ecl_grid_type* localEclGrid, size_t activeStartIndex)
bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const ecl_grid_type* localEclGrid, size_t matrixActiveStartIndex, size_t fractureActiveStartIndex)
{
int cellCount = ecl_grid_get_global_size(localEclGrid);
size_t cellStartIndex = mainGrid->cells().size();
@ -109,15 +107,33 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e
{
RigCell& cell = mainGrid->cells()[cellStartIndex + gIdx];
// The invalid (tainted) cell concept in ecl was not correct at all,
// so this is disabeled.
//bool invalid = ecl_grid_cell_invalid1(localEclGrid, gIdx);
//cell.setInvalid(invalid);
bool invalid = ecl_grid_cell_invalid1(localEclGrid, gIdx);
cell.setInvalid(invalid);
cell.setCellIndex(gIdx);
bool active = ecl_grid_cell_active1(localEclGrid, gIdx);
cell.setActive(active);
cell.setGlobalActiveIndex(active ? activeStartIndex + ecl_grid_get_active_index1(localEclGrid, gIdx) : cvf::UNDEFINED_SIZE_T);
// Active cell index
int matrixActiveIndex = ecl_grid_get_active_index1(localEclGrid, gIdx);
if (matrixActiveIndex != -1)
{
cell.setActiveIndexInMatrixModel(matrixActiveStartIndex + matrixActiveIndex);
}
else
{
cell.setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
}
int fractureActiveIndex = ecl_grid_get_active_fracture_index1(localEclGrid, gIdx);
if (fractureActiveIndex != -1)
{
cell.setActiveIndexInFractureModel(fractureActiveStartIndex + fractureActiveIndex);
}
else
{
cell.setActiveIndexInFractureModel(cvf::UNDEFINED_SIZE_T);
}
// Parent cell index
int parentCellIndex = ecl_grid_get_parent_cell1(localEclGrid, gIdx);
if (parentCellIndex == -1)
@ -129,6 +145,10 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e
cell.setParentCellIndex(parentCellIndex);
}
// Coarse cell info
ecl_coarse_cell_type * coarseCellData = ecl_grid_get_cell_coarse_group1( localEclGrid , gIdx);
cell.setInCoarseCell(coarseCellData != NULL);
// Corner coordinates
int cIdx;
for (cIdx = 0; cIdx < 8; ++cIdx)
@ -148,6 +168,12 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e
cell.setSubGrid(static_cast<RigLocalGrid*>(mainGrid->gridByIndex(subGridFileIndex)));
}
// Mark inactive long pyramid looking cells as invalid
if (!invalid && (cell.isInCoarseCell() || (!cell.isActiveInMatrixModel() && !cell.isActiveInFractureModel()) ) )
{
cell.setInvalid(cell.isLongPyramidCell());
}
#pragma omp atomic
computedCellCount++;
@ -155,7 +181,6 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e
}
return true;
}
#endif
//==================================================================================================
//
@ -187,7 +212,7 @@ void RifReaderEclipseOutput::ground()
m_fileSet.clear();
m_timeSteps.clear();
m_mainGrid = NULL;
}
//--------------------------------------------------------------------------------------------------
@ -195,7 +220,7 @@ void RifReaderEclipseOutput::ground()
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::close()
{
m_staticResultsAccess = NULL;
m_ecl_file = NULL;
m_dynamicResultsAccess = NULL;
ground();
@ -208,8 +233,6 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
{
CVF_ASSERT(reservoir);
#ifdef USE_ECL_LIB
if (!mainEclGrid)
{
// Some error
@ -260,26 +283,41 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
progInfo.setProgressDescription("Main Grid");
progInfo.setNextProgressIncrement(3);
transferGridCellData(mainGrid, mainGrid, mainEclGrid, 0);
transferGridCellData(mainGrid, mainGrid, mainEclGrid, 0, 0);
progInfo.setProgress(3);
size_t globalActiveSize = ecl_grid_get_active_size(mainEclGrid);
size_t globalMatrixActiveSize = ecl_grid_get_nactive(mainEclGrid);
size_t globalFractureActiveSize = ecl_grid_get_nactive_fracture(mainEclGrid);
mainGrid->setMatrixModelActiveCellCount(globalMatrixActiveSize);
mainGrid->setFractureModelActiveCellCount(globalFractureActiveSize);
for (lgrIdx = 0; lgrIdx < numLGRs; ++lgrIdx)
{
progInfo.setProgressDescription("LGR number " + QString::number(lgrIdx+1));
ecl_grid_type* localEclGrid = ecl_grid_iget_lgr(mainEclGrid, lgrIdx);
transferGridCellData(mainGrid, static_cast<RigLocalGrid*>(mainGrid->gridByIndex(lgrIdx+1)), localEclGrid, globalActiveSize);
globalActiveSize += ecl_grid_get_active_size(localEclGrid);
RigLocalGrid* localGrid = static_cast<RigLocalGrid*>(mainGrid->gridByIndex(lgrIdx+1));
transferGridCellData(mainGrid, localGrid, localEclGrid, globalMatrixActiveSize, globalFractureActiveSize);
int activeCellCount = ecl_grid_get_nactive(localEclGrid);
localGrid->setMatrixModelActiveCellCount(activeCellCount);
globalMatrixActiveSize += activeCellCount;
activeCellCount = ecl_grid_get_nactive_fracture(localEclGrid);
localGrid->setFractureModelActiveCellCount(activeCellCount);
globalFractureActiveSize += activeCellCount;
progInfo.setProgress(3 + lgrIdx);
}
#endif
mainGrid->setGlobalMatrixModelActiveCellCount(globalMatrixActiveSize);
mainGrid->setGlobalFractureModelActiveCellCount(globalFractureActiveSize);
return true;
}
//--------------------------------------------------------------------------------------------------
@ -288,7 +326,7 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservoir)
{
CVF_ASSERT(reservoir);
caf::ProgressInfo progInfo(10, "");
caf::ProgressInfo progInfo(100, "");
progInfo.setProgressDescription("Reading Grid");
@ -298,37 +336,46 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservo
// Get set of files
QStringList fileSet;
if (!RifEclipseOutputFileTools::fileSet(fileName, &fileSet)) return false;
progInfo.incrementProgress();
progInfo.setNextProgressIncrement(20);
// Keep the set of files of interest
m_fileSet = fileSet;
// Read geometry
#ifdef USE_ECL_LIB
ecl_grid_type * mainEclGrid = ecl_grid_alloc( fileName.toAscii().data() );
progInfo.setProgress(1);
progInfo.setNextProgressIncrement(6);
progInfo.incrementProgress();
progInfo.setNextProgressIncrement(10);
progInfo.setProgressDescription("Transferring grid geometry");
if (!transferGeometry(mainEclGrid, reservoir)) return false;
progInfo.setProgress(7);
progInfo.setProgressDescription("Releasing reader memory");
progInfo.incrementProgress();
progInfo.setProgressDescription("Releasing reader memory");
ecl_grid_free( mainEclGrid );
progInfo.incrementProgress();
progInfo.setProgress(8);
progInfo.setProgressDescription("Reading Result index");
progInfo.setNextProgressIncrement(60);
#endif
m_mainGrid = reservoir->mainGrid();
reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this);
reservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this);
// Build results meta data
if (!buildMetaData(reservoir)) return false;
progInfo.incrementProgress();
progInfo.setProgress(9);
progInfo.setNextProgressIncrement(8);
progInfo.setProgressDescription("Reading Well information");
readWellCells(reservoir);
return true;
}
@ -337,87 +384,120 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservo
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
{
#ifdef USE_ECL_LIB
CVF_ASSERT(reservoir);
CVF_ASSERT(m_fileSet.size() > 0);
caf::ProgressInfo progInfo(2,"");
caf::ProgressInfo progInfo(m_fileSet.size() + 3,"");
// Get the number of active cells in the grid
size_t numActiveCells = reservoir->mainGrid()->numActiveCells();
size_t numGrids = reservoir->mainGrid()->gridCount();
progInfo.setNextProgressIncrement(m_fileSet.size());
// Create access object for dynamic results
m_dynamicResultsAccess = dynamicResultsAccess(m_fileSet, numGrids, numActiveCells);
m_dynamicResultsAccess = dynamicResultsAccess(m_fileSet);
if (m_dynamicResultsAccess.isNull())
{
return false;
}
RigReservoirCellResults* resCellResults = reservoir->mainGrid()->results();
progInfo.incrementProgress();
RigReservoirCellResults* matrixModelResults = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS);
RigReservoirCellResults* fractureModelResults = reservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS);
if (m_dynamicResultsAccess.notNull())
{
// Get time steps
m_timeSteps = m_dynamicResultsAccess->timeSteps();
// Get the names of the dynamic results
QStringList dynamicResultNames = m_dynamicResultsAccess->resultNames();
QStringList resultNames;
std::vector<size_t> resultNamesDataItemCounts;
m_dynamicResultsAccess->resultNames(&resultNames, &resultNamesDataItemCounts);
for (size_t i = 0; i < static_cast<size_t>(dynamicResultNames.size()); ++i)
{
size_t resIndex = resCellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, dynamicResultNames[i]);
resCellResults->setTimeStepDates(resIndex, m_timeSteps);
QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::MATRIX_RESULTS, m_dynamicResultsAccess->timeStepCount());
for (int i = 0; i < matrixResultNames.size(); ++i)
{
size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, matrixResultNames[i]);
matrixModelResults->setTimeStepDates(resIndex, m_timeSteps);
}
}
{
QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::FRACTURE_RESULTS, m_dynamicResultsAccess->timeStepCount());
for (int i = 0; i < fractureResultNames.size(); ++i)
{
size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, fractureResultNames[i]);
fractureModelResults->setTimeStepDates(resIndex, m_timeSteps);
}
}
}
progInfo.setProgress(1);
progInfo.incrementProgress();
QString initFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_INIT_FILE);
if (initFileName.size() > 0)
{
// Open init file
cvf::ref<RifEclipseOutputFileTools> initFile = new RifEclipseOutputFileTools;
if (!initFile->open(initFileName))
ecl_file_type* ecl_file = ecl_file_open(initFileName.toAscii().data());
if (!ecl_file) return false;
progInfo.incrementProgress();
QStringList resultNames;
std::vector<size_t> resultNamesDataItemCounts;
RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(ecl_file, &resultNames, &resultNamesDataItemCounts);
{
return false;
QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::MATRIX_RESULTS, 1);
QList<QDateTime> staticDate;
if (m_timeSteps.size() > 0)
{
staticDate.push_back(m_timeSteps.front());
}
for (int i = 0; i < matrixResultNames.size(); ++i)
{
size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, matrixResultNames[i]);
matrixModelResults->setTimeStepDates(resIndex, staticDate);
}
}
// Get the names of the static results
QStringList staticResults;
initFile->keywordsOnFile(&staticResults, numActiveCells);
QStringList staticResultNames = staticResults;
QList<QDateTime> staticDate;
if (m_timeSteps.size() > 0)
{
staticDate.push_back(m_timeSteps.front());
QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::FRACTURE_RESULTS, 1);
QList<QDateTime> staticDate;
if (m_timeSteps.size() > 0)
{
staticDate.push_back(m_timeSteps.front());
}
for (int i = 0; i < fractureResultNames.size(); ++i)
{
size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, fractureResultNames[i]);
fractureModelResults->setTimeStepDates(resIndex, staticDate);
}
}
for (size_t i = 0; i < static_cast<size_t>(staticResultNames.size()); ++i)
{
size_t resIndex = resCellResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, staticResultNames[i]);
resCellResults->setTimeStepDates(resIndex, staticDate);
}
m_staticResultsAccess = initFile;
m_ecl_file = ecl_file;
}
return true;
#else
return false;
#endif //USE_ECL_LIB
}
//--------------------------------------------------------------------------------------------------
/// Create results access object (.UNRST or .X0001 ... .XNNNN)
//--------------------------------------------------------------------------------------------------
RifEclipseRestartDataAccess* RifReaderEclipseOutput::dynamicResultsAccess(const QStringList& fileSet, size_t numGrids, size_t numActiveCells)
RifEclipseRestartDataAccess* RifReaderEclipseOutput::dynamicResultsAccess(const QStringList& fileSet)
{
RifEclipseRestartDataAccess* resultsAccess = NULL;
#ifdef USE_ECL_LIB
// Look for unified restart file
QString unrstFileName = RifEclipseOutputFileTools::fileNameByType(fileSet, ECL_UNIFIED_RESTART_FILE);
if (unrstFileName.size() > 0)
{
resultsAccess = new RifEclipseUnifiedRestartFileAccess(numGrids, numActiveCells);
resultsAccess = new RifEclipseUnifiedRestartFileAccess();
if (!resultsAccess->open(QStringList(unrstFileName)))
{
delete resultsAccess;
@ -430,7 +510,7 @@ RifEclipseRestartDataAccess* RifReaderEclipseOutput::dynamicResultsAccess(const
QStringList restartFiles = RifEclipseOutputFileTools::fileNamesByType(fileSet, ECL_RESTART_FILE);
if (restartFiles.size() > 0)
{
resultsAccess = new RifEclipseRestartFilesetAccess(numGrids, numActiveCells);
resultsAccess = new RifEclipseRestartFilesetAccess();
if (!resultsAccess->open(restartFiles))
{
delete resultsAccess;
@ -438,7 +518,6 @@ RifEclipseRestartDataAccess* RifReaderEclipseOutput::dynamicResultsAccess(const
}
}
}
#endif //USE_ECL_LIB
// !! could add support for formatted result files
// !! consider priorities in case multiple types exist (.UNRST, .XNNNN, ...)
@ -449,38 +528,43 @@ RifEclipseRestartDataAccess* RifReaderEclipseOutput::dynamicResultsAccess(const
//--------------------------------------------------------------------------------------------------
/// Get all values of a given static result as doubles
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::staticResult(const QString& result, std::vector<double>* values)
bool RifReaderEclipseOutput::staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values)
{
CVF_ASSERT(values);
CVF_ASSERT(m_staticResultsAccess.notNull());
CVF_ASSERT(m_ecl_file);
size_t numOccurrences = m_staticResultsAccess->numOccurrences(result);
std::vector<double> fileValues;
size_t numOccurrences = ecl_file_get_num_named_kw(m_ecl_file, result.toAscii().data());
size_t i;
for (i = 0; i < numOccurrences; i++)
{
std::vector<double> partValues;
if (!m_staticResultsAccess->keywordData(result, i, &partValues)) return false;
values->insert(values->end(), partValues.begin(), partValues.end());
RifEclipseOutputFileTools::keywordData(m_ecl_file, result, i, &partValues);
fileValues.insert(fileValues.end(), partValues.begin(), partValues.end());
}
extractResultValuesBasedOnPorosityModel(matrixOrFracture, values, fileValues);
return true;
}
//--------------------------------------------------------------------------------------------------
/// Get dynamic result at given step index. Will concatenate values for the main grid and all sub grids.
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values)
bool RifReaderEclipseOutput::dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values)
{
CVF_ASSERT(m_dynamicResultsAccess.notNull());
return m_dynamicResultsAccess->results(result, stepIndex, values);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QList<QDateTime>& RifReaderEclipseOutput::timeSteps() const
{
return m_timeSteps;
std::vector<double> fileValues;
if (!m_dynamicResultsAccess->results(result, stepIndex, m_mainGrid->gridCount(), &fileValues))
{
return false;
}
extractResultValuesBasedOnPorosityModel(matrixOrFracture, values, fileValues);
return true;
}
//--------------------------------------------------------------------------------------------------
@ -492,7 +576,6 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
if (m_dynamicResultsAccess.isNull()) return;
#ifdef USE_ECL_LIB
well_info_type* ert_well_info = well_info_alloc(NULL);
if (!ert_well_info) return;
@ -503,6 +586,7 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
reservoir->allGrids(&grids);
cvf::Collection<RigWellResults> wells;
caf::ProgressInfo progress(well_info_get_num_wells(ert_well_info), "");
int wellIdx;
for (wellIdx = 0; wellIdx < well_info_get_num_wells(ert_well_info); wellIdx++)
@ -566,7 +650,7 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
bool hasWellConnectionsInLGR = false;
for (size_t gridNr = 1; gridNr < grids.size(); ++gridNr)
{
int branchCount = well_state_iget_lgr_num_branches(ert_well_state, gridNr);
int branchCount = well_state_iget_lgr_num_branches(ert_well_state, static_cast<int>(gridNr));
if (branchCount > 0)
{
hasWellConnectionsInLGR = true;
@ -578,18 +662,26 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
{
// Wellhead. If several grids have a wellhead definition for this well, we use tha last one. (Possibly the innermost LGR)
const well_conn_type* ert_wellhead = well_state_iget_wellhead(ert_well_state, gridNr);
const well_conn_type* ert_wellhead = well_state_iget_wellhead(ert_well_state, static_cast<int>(gridNr));
if (ert_wellhead)
{
int cellI = well_conn_get_i( ert_wellhead );
int cellJ = well_conn_get_j( ert_wellhead );
int cellK = CVF_MAX(0, well_conn_get_k(ert_wellhead)); // Why this ?
// If a well is defined in fracture region, the K-value is from (cellCountK - 1) -> cellCountK*2 - 1
// Adjust K so index is always in valid grid region
if (cellK >= grids[gridNr]->cellCountK())
{
cellK -= static_cast<int>(grids[gridNr]->cellCountK());
}
wellResFrame.m_wellHead.m_gridCellIndex = grids[gridNr]->cellIndexFromIJK(cellI, cellJ, cellK);
wellResFrame.m_wellHead.m_gridIndex = gridNr;
int gridK = CVF_MAX(0, well_conn_get_k(ert_wellhead)); // Why this ?
int gridI = well_conn_get_i( ert_wellhead );
int gridJ = well_conn_get_j( ert_wellhead );
wellResFrame.m_wellHead.m_gridCellIndex = grids[gridNr]->cellIndexFromIJK(gridI, gridJ, gridK);
}
int branchCount = well_state_iget_lgr_num_branches(ert_well_state, gridNr);
int branchCount = well_state_iget_lgr_num_branches(ert_well_state, static_cast<int>(gridNr));
if (branchCount > 0)
{
if (static_cast<int>(wellResFrame.m_wellResultBranches.size()) < branchCount) wellResFrame.m_wellResultBranches.resize(branchCount);
@ -597,7 +689,7 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
for (int branchIdx = 0; branchIdx < branchCount; ++branchIdx )
{
// Connections
int connectionCount = well_state_iget_num_lgr_connections(ert_well_state, gridNr, branchIdx);
int connectionCount = well_state_iget_num_lgr_connections(ert_well_state, static_cast<int>(gridNr), branchIdx);
if (connectionCount > 0)
{
@ -609,20 +701,27 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
int connIdx;
for (connIdx = 0; connIdx < connectionCount; connIdx++)
{
const well_conn_type* ert_connection = well_state_iget_lgr_connections( ert_well_state, gridNr, branchIdx)[connIdx];
const well_conn_type* ert_connection = well_state_iget_lgr_connections( ert_well_state, static_cast<int>(gridNr), branchIdx)[connIdx];
CVF_ASSERT(ert_connection);
RigWellResultCell& data = wellSegment.m_wellCells[existingConnCount + connIdx];
data.m_gridIndex = gridNr;
{
int connI = well_conn_get_i( ert_connection );
int connJ = well_conn_get_j( ert_connection );
int connK = well_conn_get_k( ert_connection );
int cellI = well_conn_get_i( ert_connection );
int cellJ = well_conn_get_j( ert_connection );
int cellK = well_conn_get_k( ert_connection );
bool open = well_conn_open( ert_connection );
int branch = well_conn_get_branch( ert_connection );
int segment = well_conn_get_segment( ert_connection );
data.m_gridCellIndex = grids[gridNr]->cellIndexFromIJK(connI , connJ , connK);
// If a well is defined in fracture region, the K-value is from (cellCountK - 1) -> cellCountK*2 - 1
// Adjust K so index is always in valid grid region
if (cellK >= grids[gridNr]->cellCountK())
{
cellK -= static_cast<int>(grids[gridNr]->cellCountK());
}
data.m_gridCellIndex = grids[gridNr]->cellIndexFromIJK(cellI , cellJ , cellK);
data.m_isOpen = open;
data.m_branchId = branch;
@ -638,13 +737,128 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
wellResults->computeMappingFromResultTimeIndicesToWellTimeIndices(m_timeSteps);
wells.push_back(wellResults.p());
progress.incrementProgress();
}
well_info_free(ert_well_info);
reservoir->setWellResults(wells);
#endif
}
//--------------------------------------------------------------------------------------------------
// For case DUALPORO, the well K index is reported outside the grid. If this happens,
// for the given IJ position, search from K=0 and upwards for first active cell.
//--------------------------------------------------------------------------------------------------
int RifReaderEclipseOutput::findSmallestActiveCellIndexK(const RigGridBase* grid, int cellI, int cellJ)
{
if (!grid) return -1;
for (int candidateCellK = 0; candidateCellK < grid->cellCountK(); candidateCellK++ )
{
if (grid->isCellActive(cellI, cellJ, candidateCellK))
{
return candidateCellK;
}
}
return -1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringList& keywords, const std::vector<size_t>& keywordDataItemCounts, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const
{
if (keywords.size() != keywordDataItemCounts.size())
{
return QStringList();
}
if (matrixOrFracture == RifReaderInterface::FRACTURE_RESULTS)
{
if (m_mainGrid->globalFractureModelActiveCellCount() == 0)
{
return QStringList();
}
}
QStringList keywordsWithCorrectNumberOfDataItems;
for (int i = 0; i < keywords.size(); i++)
{
QString keyword = keywords[i];
size_t keywordDataCount = keywordDataItemCounts[i];
size_t timeStepsMatrix = keywordDataItemCounts[i] / m_mainGrid->globalMatrixModelActiveCellCount();
size_t timeStepsMatrixRest = keywordDataItemCounts[i] % m_mainGrid->globalMatrixModelActiveCellCount();
size_t timeStepsMatrixAndFracture = keywordDataItemCounts[i] / (m_mainGrid->globalMatrixModelActiveCellCount() + m_mainGrid->globalFractureModelActiveCellCount());
size_t timeStepsMatrixAndFractureRest = keywordDataItemCounts[i] % (m_mainGrid->globalMatrixModelActiveCellCount() + m_mainGrid->globalFractureModelActiveCellCount());
if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS)
{
if (timeStepsMatrixRest == 0 || timeStepsMatrixAndFractureRest == 0)
{
if (timeStepCount == timeStepsMatrix || timeStepCount == timeStepsMatrixAndFracture)
{
keywordsWithCorrectNumberOfDataItems.push_back(keywords[i]);
}
}
}
else
{
if (timeStepsMatrixAndFractureRest == 0 && timeStepCount == timeStepsMatrixAndFracture)
{
keywordsWithCorrectNumberOfDataItems.push_back(keywords[i]);
}
}
}
return keywordsWithCorrectNumberOfDataItems;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector<double>* destinationResultValues, const std::vector<double>& sourceResultValues)
{
if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS)
{
if (m_mainGrid->globalFractureModelActiveCellCount() == 0)
{
destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin(), sourceResultValues.end());
}
else
{
size_t dataItemCount = 0;
size_t sourceStartPosition = 0;
for (size_t i = 0; i < m_mainGrid->gridCount(); i++)
{
size_t matrixActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount();
size_t fractureActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount();
destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin() + sourceStartPosition, sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount);
sourceStartPosition += (matrixActiveCellCount + fractureActiveCellCount);
}
}
}
else
{
size_t dataItemCount = 0;
size_t sourceStartPosition = 0;
for (size_t i = 0; i < m_mainGrid->gridCount(); i++)
{
size_t matrixActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount();
size_t fractureActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount();
destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount, sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount + fractureActiveCellCount);
sourceStartPosition += (matrixActiveCellCount + fractureActiveCellCount);
}
}
}

View File

@ -24,8 +24,12 @@
class RifEclipseOutputFileTools;
class RifEclipseRestartDataAccess;
class RigGridBase;
class RigMainGrid;
typedef struct ecl_grid_struct ecl_grid_type;
typedef struct ecl_file_struct ecl_file_type;
//==================================================================================================
//
@ -41,29 +45,33 @@ public:
bool open(const QString& fileName, RigReservoir* reservoir);
void close();
const QList<QDateTime>& timeSteps() const;
bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values);
bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values);
bool staticResult(const QString& result, std::vector<double>* values);
bool dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values);
#ifdef USE_ECL_LIB
static bool transferGeometry(const ecl_grid_type* mainEclGrid, RigReservoir* reservoir);
#endif
private:
void ground();
bool buildMetaData(RigReservoir* reservoir);
void readWellCells(RigReservoir* reservoir);
static RifEclipseRestartDataAccess* staticResultsAccess(const QStringList& fileSet, size_t numGrids, size_t numActiveCells);
static RifEclipseRestartDataAccess* dynamicResultsAccess(const QStringList& fileSet, size_t numGrids, size_t numActiveCells);
void extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector<double>* values, const std::vector<double>& fileValues);
int findSmallestActiveCellIndexK( const RigGridBase* grid, int cellI, int cellJ);
static RifEclipseRestartDataAccess* staticResultsAccess(const QStringList& fileSet);
static RifEclipseRestartDataAccess* dynamicResultsAccess(const QStringList& fileSet);
QStringList validKeywordsForPorosityModel(const QStringList& keywords, const std::vector<size_t>& keywordDataItemCounts, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const;
private:
QString m_fileName; // Name of file used to start accessing Eclipse output files
QStringList m_fileSet; // Set of files in filename's path with same base name as filename
QString m_fileName; // Name of file used to start accessing Eclipse output files
QStringList m_fileSet; // Set of files in filename's path with same base name as filename
QList<QDateTime> m_timeSteps;
cvf::cref<RigMainGrid> m_mainGrid;
cvf::ref<RifEclipseOutputFileTools> m_staticResultsAccess; // File access to static results
cvf::ref<RifEclipseRestartDataAccess> m_dynamicResultsAccess; // File access to dynamic results
QList<QDateTime> m_timeSteps;
ecl_file_type* m_ecl_file; // File access to static results
cvf::ref<RifEclipseRestartDataAccess> m_dynamicResultsAccess; // File access to dynamic results
};

View File

@ -35,6 +35,13 @@ class RigReservoir;
//==================================================================================================
class RifReaderInterface : public cvf::Object
{
public:
enum PorosityModelResultType
{
MATRIX_RESULTS,
FRACTURE_RESULTS
};
public:
RifReaderInterface() {}
virtual ~RifReaderInterface() {}
@ -42,8 +49,7 @@ public:
virtual bool open(const QString& fileName, RigReservoir* reservoir) = 0;
virtual void close() = 0;
virtual bool staticResult(const QString& result, std::vector<double>* values) = 0;
virtual bool dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values) = 0;
virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values) = 0;
virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values) = 0;
};

View File

@ -20,6 +20,7 @@
#include "RifReaderMockModel.h"
#include "RigReservoirCellResults.h"
#include "RifReaderInterface.h"
//--------------------------------------------------------------------------------------------------
///
@ -30,12 +31,12 @@ bool RifReaderMockModel::open(const QString& fileName, RigReservoir* reservoir)
m_reservoir = reservoir;
RigReservoirCellResults* cellResults = reservoir->mainGrid()->results();
RigReservoirCellResults* cellResults = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS);
QList<QDateTime> dates;
for (size_t i = 0; i < m_reservoirBuilder.timeStepCount(); i++)
for (int i = 0; i < static_cast<int>(m_reservoirBuilder.timeStepCount()); i++)
{
dates.push_back(QDateTime(QDate(2012+i, 6, 1)));
}
@ -50,7 +51,7 @@ bool RifReaderMockModel::open(const QString& fileName, RigReservoir* reservoir)
QList<QDateTime> staticDates;
staticDates.push_back(dates[0]);
for (size_t i = 0; i < m_reservoirBuilder.resultCount(); i++)
for (int i = 0; i < static_cast<int>(m_reservoirBuilder.resultCount()); i++)
{
QString varEnd;
if (i == 0) varEnd = "X";
@ -101,7 +102,7 @@ bool RifReaderMockModel::inputProperty(const QString& propertyName, std::vector<
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderMockModel::staticResult(const QString& result, std::vector<double>* values)
bool RifReaderMockModel::staticResult(const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, std::vector<double>* values)
{
m_reservoirBuilder.staticResult(m_reservoir.p(), result, values);
@ -111,7 +112,7 @@ bool RifReaderMockModel::staticResult(const QString& result, std::vector<double>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderMockModel::dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values)
bool RifReaderMockModel::dynamicResult(const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values)
{
m_reservoirBuilder.dynamicResult(m_reservoir.p(), result, stepIndex, values);

View File

@ -36,8 +36,8 @@ public:
virtual bool open( const QString& fileName, RigReservoir* reservoir );
virtual void close();
virtual bool staticResult( const QString& result, std::vector<double>* values );
virtual bool dynamicResult( const QString& result, size_t stepIndex, std::vector<double>* values );
virtual bool staticResult( const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, std::vector<double>* values );
virtual bool dynamicResult( const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values );
private:
void populateReservoir(RigReservoir* reservoir);

View File

@ -101,7 +101,8 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
timeStepIndex = 0;
}
cellScalarResultUseGlobalActiveIndex = grid->mainGrid()->results()->isUsingGlobalActiveIndex(cellResultSlot->gridScalarIndex());
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
cellScalarResultUseGlobalActiveIndex = grid->mainGrid()->results(porosityModel)->isUsingGlobalActiveIndex(cellResultSlot->gridScalarIndex());
}
size_t resultIndices[6];
@ -114,7 +115,7 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
{
if (resultIndices[cubeFaceIdx] != cvf::UNDEFINED_SIZE_T)
{
edgeScalarResultUseGlobalActiveIndex[cubeFaceIdx] = grid->mainGrid()->results()->isUsingGlobalActiveIndex(resultIndices[cubeFaceIdx]);
edgeScalarResultUseGlobalActiveIndex[cubeFaceIdx] = grid->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->isUsingGlobalActiveIndex(resultIndices[cubeFaceIdx]);
}
}
}
@ -140,11 +141,12 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
size_t resultValueIndex = cellIndex;
if (cellScalarResultUseGlobalActiveIndex)
{
resultValueIndex = grid->cell(cellIndex).globalActiveIndex();
resultValueIndex = grid->cell(cellIndex).activeIndexInMatrixModel();
}
{
double scalarValue = grid->mainGrid()->results()->cellScalarResult(timeStepIndex, cellResultSlot->gridScalarIndex(), resultValueIndex);
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
double scalarValue = grid->mainGrid()->results(porosityModel)->cellScalarResult(timeStepIndex, cellResultSlot->gridScalarIndex(), resultValueIndex);
if (scalarValue != HUGE_VAL)
{
cellColorTextureCoord = cellResultScalarMapper->mapToTextureCoord(scalarValue)[0];
@ -169,11 +171,11 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
resultValueIndex = cellIndex;
if (edgeScalarResultUseGlobalActiveIndex[cubeFaceIdx])
{
resultValueIndex = grid->cell(cellIndex).globalActiveIndex();
resultValueIndex = grid->cell(cellIndex).activeIndexInMatrixModel();
}
// Assuming static values to be mapped onto cell edge, always using time step zero
double scalarValue = grid->mainGrid()->results()->cellScalarResult(0, resultIndices[cubeFaceIdx], resultValueIndex);
double scalarValue = grid->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResult(0, resultIndices[cubeFaceIdx], resultValueIndex);
if (scalarValue != HUGE_VAL && scalarValue != ignoredScalarValue)
{
edgeColor = edgeResultScalarMapper->mapToTextureCoord(scalarValue)[0];

View File

@ -27,6 +27,8 @@
#include "RimReservoirView.h"
#include "RimResultSlot.h"
#include "RimCellEdgeResultSlot.h"
#include "RigGridScalarDataAccess.h"
#include "RigReservoirCellResults.h"
//--------------------------------------------------------------------------------------------------
@ -35,7 +37,8 @@
RivGridPartMgr::RivGridPartMgr(const RigGridBase* grid, size_t gridIdx)
: m_surfaceGenerator(grid),
m_faultGenerator(grid),
m_gridIdx(gridIdx),
m_gridIdx(gridIdx),
m_grid(grid),
m_surfaceFaceFilter(grid),
m_faultFaceFilter(grid),
m_opacityLevel(1.0f),
@ -217,10 +220,14 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
size_t resTimeStepIdx = timeStepIndex;
if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0;
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
cvf::ref<RigGridScalarDataAccess> dataAccessObject = m_grid->dataAccessObject(porosityModel, resTimeStepIdx, scalarSetIndex);
if (dataAccessObject.isNull()) return;
// Outer surface
if (m_surfaceFaces.notNull())
{
m_surfaceGenerator.textureCoordinates(m_surfaceFacesTextureCoords.p(), resTimeStepIdx, scalarSetIndex, mapper);
m_surfaceGenerator.textureCoordinates(m_surfaceFacesTextureCoords.p(), dataAccessObject.p(), mapper);
for(size_t i = 0; i < m_surfaceFacesTextureCoords->size(); ++i)
{
@ -246,7 +253,7 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
// Faults
if (m_faultFaces.notNull())
{
m_faultGenerator.textureCoordinates(m_faultFacesTextureCoords.p(), resTimeStepIdx, scalarSetIndex, mapper);
m_faultGenerator.textureCoordinates(m_faultFacesTextureCoords.p(), dataAccessObject.p(), mapper);
for(size_t i = 0; i < m_faultFacesTextureCoords->size(); ++i)
{

View File

@ -69,6 +69,8 @@ private:
private:
size_t m_gridIdx;
cvf::cref<RigGridBase> m_grid;
cvf::ref<cvf::Transform> m_scaleTransform;
float m_opacityLevel;
cvf::Color3f m_defaultColor;

View File

@ -222,7 +222,7 @@ cvf::ref<cvf::DrawableGeo> RivPipeGeometryGenerator::generateLine(const cvf::Vec
size_t i;
for (i = 0; i < duplicateVertexCount; i++)
{
indices->set(i, i);
indices->set(i, static_cast<cvf::uint>(i));
}
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;

View File

@ -23,6 +23,7 @@
#include "RigReservoir.h"
#include "RigGridBase.h"
#include "RigReservoirCellResults.h"
#include "RigGridScalarDataAccess.h"
//--------------------------------------------------------------------------------------------------
///
@ -475,8 +476,8 @@ void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisib
const RigCell& cell = grid->cell(cellIndex);
if ( !invalidCellsIsVisible && cell.isInvalid()
|| !inactiveCellsIsVisible && !cell.active()
|| !activeCellsIsVisible && cell.active()
|| !inactiveCellsIsVisible && !cell.isActiveInMatrixModel()
|| !activeCellsIsVisible && cell.isActiveInMatrixModel()
|| mainGridIsVisible && (cell.subGrid() != NULL)
|| cell.isWellCell()
)
@ -597,7 +598,10 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis
}
const RimCellFilter::FilterModeType filterType = (*pfIt)->filterMode();
bool useGlobalActiveIndex = grid->mainGrid()->results()->isUsingGlobalActiveIndex((*pfIt)->resultDefinition->gridScalarIndex());
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel((*pfIt)->resultDefinition()->porosityModel());
cvf::ref<RigGridScalarDataAccess> dataAccessObject = grid->dataAccessObject(porosityModel, timeStepIndex, scalarResultIndex);
CVF_ASSERT(dataAccessObject.notNull());
#pragma omp parallel for schedule(dynamic)
for (int cellIndex = 0; cellIndex < static_cast<int>(grid->cellCount()); cellIndex++)
@ -605,12 +609,8 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis
if ( (*cellVisibility)[cellIndex] )
{
size_t resultValueIndex = cellIndex;
if (useGlobalActiveIndex)
{
resultValueIndex = grid->cell(cellIndex).globalActiveIndex();
}
double scalarValue = grid->mainGrid()->results()->cellScalarResult(timeStepIndex, scalarResultIndex, resultValueIndex);
double scalarValue = dataAccessObject->cellScalar(resultValueIndex);
if (lowerBound <= scalarValue && scalarValue <= upperBound)
{
if (filterType == RimCellFilter::EXCLUDE)

View File

@ -266,7 +266,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
{
if (m_rimReservoirView.isNull()) return;
if (m_rimWell.isNull()) return;
if (m_rimWell.isNull() || m_rimWell->wellResults() == NULL) return;
if ( m_rimReservoirView->wellCollection()->wellPipeVisibility() != RimWellCollection::FORCE_ALL_ON
&& m_rimWell->showWellPipes() == false) return;

View File

@ -325,7 +325,7 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
void RivWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
{
if (m_rimReservoirView.isNull()) return;
if (m_rimWell.isNull()) return;
if (m_rimWell.isNull() || m_rimWell->wellResults() == NULL) return;
if ( m_rimReservoirView->wellCollection()->wellPipeVisibility() != RimWellCollection::FORCE_ALL_ON
&& m_rimWell->showWellPipes() == false) return;

View File

@ -89,7 +89,7 @@ void Rim3dOverlayInfoConfig::update3DInfo()
{
caseName = m_reservoirView->eclipseCase()->caseName();
totCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cells().size());
activeCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->numActiveCells());
activeCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->globalMatrixModelActiveCellCount());
iSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountI());
jSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountJ());
kSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountK());

View File

@ -119,7 +119,7 @@ void RimCellRangeFilter::setDefaultValues()
if (mainGrid)
{
cvf::Vec3st min, max;
mainGrid->activeCellsBoundingBox(min, max);
mainGrid->matrixModelActiveCellsBoundingBox(min, max);
// Adjust to Eclipse indexing
min.x() = min.x() + 1;
@ -130,12 +130,12 @@ void RimCellRangeFilter::setDefaultValues()
max.y() = max.y() + 1;
max.z() = max.z() + 1;
startIndexI = min.x();
startIndexJ = min.y();
startIndexK = min.z();
cellCountI = max.x() - min.x() + 1;
cellCountJ = max.y() - min.y() + 1;
cellCountK = max.z() - min.z() + 1;
startIndexI = static_cast<int>(min.x());
startIndexJ = static_cast<int>(min.y());
startIndexK = static_cast<int>(min.z());
cellCountI = static_cast<int>(max.x() - min.x() + 1);
cellCountJ = static_cast<int>(max.y() - min.y() + 1);
cellCountK = static_cast<int>(max.z() - min.z() + 1);
}
}
@ -162,7 +162,7 @@ void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field,
if (mainGrid)
{
cvf::Vec3st min, max;
mainGrid->activeCellsBoundingBox(min, max);
mainGrid->matrixModelActiveCellsBoundingBox(min, max);
// Adjust to Eclipse indexing
min.x() = min.x() + 1;
@ -183,17 +183,17 @@ void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field,
if (field == &startIndexI || field == &cellCountI)
{
myAttr->m_minimum = 1;
myAttr->m_maximum = mainGrid->cellCountI();
myAttr->m_maximum = static_cast<int>(mainGrid->cellCountI());
}
else if (field == &startIndexJ || field == &cellCountJ)
{
myAttr->m_minimum = 1;
myAttr->m_maximum = mainGrid->cellCountJ();
myAttr->m_maximum = static_cast<int>(mainGrid->cellCountJ());
}
else if (field == &startIndexK || field == &cellCountK)
{
myAttr->m_minimum = 1;
myAttr->m_maximum = mainGrid->cellCountK();
myAttr->m_maximum = static_cast<int>(mainGrid->cellCountK());
}
}
}

View File

@ -34,5 +34,15 @@ namespace caf
setDefault(RimDefines::DYNAMIC_NATIVE);
}
template<>
void caf::AppEnum< RimDefines::PorosityModelType >::setUp()
{
addItem(RimDefines::MATRIX_MODEL, "MATRIX_MODEL", "Matrix");
addItem(RimDefines::FRACTURE_MODEL, "FRACTURE_MODEL", "Fracture");
setDefault(RimDefines::MATRIX_MODEL);
}
}

View File

@ -33,6 +33,12 @@ public:
REMOVED
};
enum PorosityModelType
{
MATRIX_MODEL,
FRACTURE_MODEL
};
static QString undefinedResultName() { return "None"; }
};

View File

@ -72,7 +72,30 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames)
if (caseName().contains("Input Mock Debug Model"))
{
cvf::ref<RifReaderInterface> readerInterface = this->createMockModel(this->caseName());
m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p());
m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
size_t matrixActiveCellCount = 0;
size_t fractureActiveCellCount = 0;
for (size_t cellIdx = 0; cellIdx < m_rigReservoir->mainGrid()->cells().size(); cellIdx++)
{
const RigCell& cell = m_rigReservoir->mainGrid()->cells()[cellIdx];
if (cell.isActiveInMatrixModel())
{
matrixActiveCellCount++;
}
if (cell.isActiveInFractureModel())
{
fractureActiveCellCount++;
}
}
m_rigReservoir->mainGrid()->setGlobalMatrixModelActiveCellCount(matrixActiveCellCount);
m_rigReservoir->mainGrid()->setGlobalFractureModelActiveCellCount(fractureActiveCellCount);
return;
}
@ -179,16 +202,21 @@ bool RimInputReservoir::openEclipseGridFile()
CVF_ASSERT(m_rigReservoir.notNull());
CVF_ASSERT(readerInterface.notNull());
m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p());
m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
m_rigReservoir->computeFaults();
m_rigReservoir->mainGrid()->computeCachedData();
}
RigReservoirCellResults* results = m_rigReservoir->mainGrid()->results();
RIApplication* app = RIApplication::instance();
if (app->preferences()->autocomputeDepthRelatedProperties)
{
results->computeDepthRelatedResults();
RigReservoirCellResults* matrixResults = m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS);
RigReservoirCellResults* fractureResults = m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS);
matrixResults->computeDepthRelatedResults();
fractureResults->computeDepthRelatedResults();
}
return true;
@ -215,12 +243,12 @@ void RimInputReservoir::loadAndSyncronizeInputProperties()
size_t inputPropCount = this->m_inputPropertyCollection()->inputProperties.size();
caf::ProgressInfo progInfo(filenames.size() *( inputPropCount + knownKeywords.size()), "Reading Input properties" );
caf::ProgressInfo progInfo(static_cast<int>(filenames.size() *( inputPropCount + knownKeywords.size())), "Reading Input properties" );
int progress = 0;
for_all(filenames, i)
{
progress = i*( inputPropCount + knownKeywords.size());
progress = static_cast<int>(i*( inputPropCount + knownKeywords.size()));
// Find all the keywords present on the file
progInfo.setProgressDescription(filenames[i]);
@ -262,10 +290,10 @@ void RimInputReservoir::loadAndSyncronizeInputProperties()
fileKeywordSet.erase(kw);
}
progInfo.setProgress(progress + ipIdx );
progInfo.setProgress(static_cast<int>(progress + ipIdx) );
}
progInfo.setProgress(progress + inputPropCount);
progInfo.setProgress(static_cast<int>(progress + inputPropCount));
// Check if there are more known property keywords left on file. If it is, read them and create inputProperty objects
if (!fileKeywordSet.empty())
@ -277,7 +305,7 @@ void RimInputReservoir::loadAndSyncronizeInputProperties()
{
if (fileKeywordSet.count(knownKeywords[fkIt]))
{
QString resultName = this->reservoirData()->mainGrid()->results()->makeResultNameUnique(knownKeywords[fkIt]);
QString resultName = this->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(knownKeywords[fkIt]);
if (RifEclipseInputFileTools::readProperty(filenames[i], this->reservoirData(), knownKeywords[fkIt], resultName))
{
RimInputProperty* inputProperty = new RimInputProperty;
@ -288,7 +316,7 @@ void RimInputReservoir::loadAndSyncronizeInputProperties()
m_inputPropertyCollection->inputProperties.push_back(inputProperty);
}
}
progInfo.setProgress(progress + inputPropCount + fkIt);
progInfo.setProgress(static_cast<int>(progress + inputPropCount + fkIt));
}
}
}
@ -352,7 +380,7 @@ void RimInputReservoir::removeProperty(RimInputProperty* inputProperty)
}
// Remove the results pointed to by this input property
RigReservoirCellResults* results = m_rigReservoir->mainGrid()->results();
RigReservoirCellResults* results = m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS);
results->removeResult(inputProperty->resultName);
this->removeResult(inputProperty->resultName);
@ -377,12 +405,12 @@ cvf::ref<RifReaderInterface> RimInputReservoir::createMockModel(QString modelNam
mockFileInterface->open("", reservoir.p());
{
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(1, 3, 4);
reservoir->mainGrid()->cell(idx).setActive(false);
reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
}
{
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(2, 2, 3);
reservoir->mainGrid()->cell(idx).setActive(false);
reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
}
// Add a property

View File

@ -209,10 +209,16 @@ void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, con
reservoirView->createDisplayModelAndRedraw();
}
RigReservoirCellResults* results = m_rigReservoir->mainGrid()->results();
if (results)
RigReservoirCellResults* matrixModelResults = m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS);
if (matrixModelResults)
{
results->clearAllResults();
matrixModelResults->clearAllResults();
}
RigReservoirCellResults* fractureModelResults = m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS);
if (fractureModelResults)
{
fractureModelResults->clearAllResults();
}
}

View File

@ -43,6 +43,7 @@
#include "cafCeetronNavigation.h"
#include "RimReservoir.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RigGridScalarDataAccess.h"
namespace caf {
@ -136,7 +137,7 @@ RimReservoirView::RimReservoirView()
CAF_PDM_InitField(&showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells", "", "", "");
CAF_PDM_InitField(&showInvalidCells, "ShowInvalidCells", false, "Show Invalid Cells", "", "", "");
//CAF_PDM_InitFieldNoDefault(&cameraPosition, "CameraPosition", "", "", "", "");
CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", "");
this->cellResult()->setReservoirView(this);
@ -260,6 +261,22 @@ void RimReservoirView::updateViewerWidgetWindowTitle()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::clampCurrentTimestep()
{
// Clamp the current timestep to actual possibilities
if (this->gridCellResults())
{
if (m_currentTimeStep() > this->gridCellResults()->maxTimeStepCount())
{
m_currentTimeStep = static_cast<int>(this->gridCellResults()->maxTimeStepCount()) -1;
}
}
if (m_currentTimeStep < 0 ) m_currentTimeStep = 0;
}
//--------------------------------------------------------------------------------------------------
///
@ -270,16 +287,11 @@ void RimReservoirView::createDisplayModelAndRedraw()
{
m_viewer->animationControl()->slotStop();
this->clampCurrentTimestep();
createDisplayModel();
updateDisplayModelVisibility();
if (m_currentTimeStep < 0 ) m_currentTimeStep = 0;
if (!this->cellResult()->hasResult() || cellResult->hasStaticResult())
{
m_currentTimeStep = 0;
}
if (m_viewer->frameCount() > 0)
{
m_viewer->animationControl()->setCurrentFrame(m_currentTimeStep);
@ -614,8 +626,7 @@ void RimReservoirView::updateCurrentTimeStep()
geometriesToRecolor.push_back(RivReservoirViewPartMgr::ALL_WELL_CELLS);
}
size_t i;
for (i = 0; i < geometriesToRecolor.size(); ++i)
for (size_t i = 0; i < geometriesToRecolor.size(); ++i)
{
if (this->animationMode() && this->cellEdgeResult()->hasResult())
@ -640,7 +651,7 @@ void RimReservoirView::updateCurrentTimeStep()
{
cvf::String modelName = "WellPipeModel";
std::vector<cvf::Model*> models;
for (i = 0; i < frameScene->modelCount(); i++)
for (cvf::uint i = 0; i < frameScene->modelCount(); i++)
{
if (frameScene->model(i)->name() == modelName)
{
@ -648,7 +659,7 @@ void RimReservoirView::updateCurrentTimeStep()
}
}
for (i = 0; i < models.size(); i++)
for (size_t i = 0; i < models.size(); i++)
{
frameScene->removeModel(models[i]);
}
@ -680,15 +691,16 @@ void RimReservoirView::loadDataAndUpdate()
if (!m_reservoir->openEclipseGridFile())
{
QMessageBox::warning(RIMainWindow::instance(), "Error when opening project file", "Could not open the Eclipse Grid file (EGRID/GRID): \n"+ m_reservoir->caseName());
m_reservoir = NULL;
return;
}
else
{
RigReservoirCellResults* results = gridCellResults();
CVF_ASSERT(results);
RIApplication* app = RIApplication::instance();
if (app->preferences()->autocomputeSOIL)
{
RigReservoirCellResults* results = gridCellResults();
CVF_ASSERT(results);
results->loadOrComputeSOIL();
}
}
@ -697,6 +709,11 @@ void RimReservoirView::loadDataAndUpdate()
CVF_ASSERT(this->cellResult() != NULL);
this->cellResult()->loadResult();
if (m_reservoir->reservoirData()->mainGrid()->globalFractureModelActiveCellCount() == 0)
{
this->cellResult->porosityModel.setUiHidden(true);
}
CVF_ASSERT(this->cellEdgeResult() != NULL);
this->cellEdgeResult()->loadResult();
@ -707,10 +724,14 @@ void RimReservoirView::loadDataAndUpdate()
m_geometry->clearGeometryCache();
syncronizeWellsWithResults();
this->clampCurrentTimestep();
createDisplayModel();
updateDisplayModelVisibility();
setDefaultView();
if (cameraPosition().isIdentity())
{
setDefaultView();
}
overlayInfoConfig()->update3DInfo();
if (animationMode && m_viewer)
@ -851,8 +872,13 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex,
const RigGridBase* grid = reservoir->grid(gridIndex);
if (this->cellResult()->hasResult())
{
double scalarValue = grid->cellScalar(m_currentTimeStep, this->cellResult()->gridScalarIndex(), cellIndex);
resultInfoText->append(QString("Cell result : %1\n").arg(scalarValue));
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel());
cvf::ref<RigGridScalarDataAccess> dataAccessObject = grid->dataAccessObject(porosityModel, m_currentTimeStep, this->cellResult()->gridScalarIndex());
if (dataAccessObject.notNull())
{
double scalarValue = dataAccessObject->cellScalar(cellIndex);
resultInfoText->append(QString("Cell result : %1\n").arg(scalarValue));
}
}
if (this->cellEdgeResult()->hasResult())
@ -862,14 +888,18 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex,
this->cellEdgeResult()->gridScalarIndices(resultIndices);
this->cellEdgeResult()->gridScalarResultNames(&resultNames);
size_t idx;
for (idx = 0; idx < 6; idx++)
for (int idx = 0; idx < 6; idx++)
{
if (resultIndices[idx] == cvf::UNDEFINED_SIZE_T) continue;
// Cell edge results are static, results are loaded for first time step only
double scalarValue = grid->cellScalar(0, resultIndices[idx], cellIndex);
resultInfoText->append(QString("%1 : %2\n").arg(resultNames[idx]).arg(scalarValue));
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel());
cvf::ref<RigGridScalarDataAccess> dataAccessObject = grid->dataAccessObject(porosityModel, 0, resultIndices[idx]);
if (dataAccessObject.notNull())
{
double scalarValue = dataAccessObject->cellScalar(cellIndex);
resultInfoText->append(QString("%1 : %2\n").arg(resultNames[idx]).arg(scalarValue));
}
}
}
}
@ -920,6 +950,7 @@ void RimReservoirView::setupBeforeSave()
if (m_viewer)
{
animationMode = m_viewer->isAnimationActive();
cameraPosition = m_viewer->mainCamera()->viewMatrix();
}
}
@ -933,7 +964,9 @@ RigReservoirCellResults* RimReservoirView::gridCellResults()
m_reservoir->reservoirData()->mainGrid()
)
{
return m_reservoir->reservoirData()->mainGrid()->results();
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult->porosityModel());
return m_reservoir->reservoirData()->mainGrid()->results(porosityModel);
}
return NULL;
@ -1002,7 +1035,8 @@ void RimReservoirView::updateLegends()
RigReservoir* reservoir = m_reservoir->reservoirData();
CVF_ASSERT(reservoir);
RigReservoirCellResults* results = reservoir->mainGrid()->results();
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel());
RigReservoirCellResults* results = reservoir->mainGrid()->results(porosityModel);
CVF_ASSERT(results);
if (this->cellResult()->hasResult())
@ -1201,7 +1235,7 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl
for ( fIdx = 0; fIdx < cellCountFenceDirection; ++fIdx)
{
size_t fenceCellIndex = grid->cellIndexFromIJK(*pI,*pJ,*pK);
if (grid->cell(fenceCellIndex).active())
if (grid->cell(fenceCellIndex).isActiveInMatrixModel())
{
(*visibleCells)[fenceCellIndex] = true;
}

View File

@ -34,6 +34,7 @@
#include "cvfMatrix4.h"
#include "cvfStructGridGeometryGenerator.h"
#include "cafPdmFieldCvfMat4d.h"
#include "RivReservoirViewPartMgr.h"
#include "RivReservoirPipesPartMgr.h"
@ -118,7 +119,7 @@ public:
// 3D Viewer
// Cam pos should be a field, but is not yet supported bu caf::Pdm
cvf::Mat4d cameraPosition;
caf::PdmField<cvf::Mat4d> cameraPosition;
void setDefaultView();
RIViewer* viewer();
@ -154,7 +155,8 @@ protected:
private:
void syncronizeWellsWithResults();
void syncronizeWellsWithResults();
void clampCurrentTimestep();
private:
caf::PdmField<int> m_currentTimeStep;
@ -173,7 +175,6 @@ private:
void updateStaticCellColors(unsigned short geometryType);
void updateLegends();
cvf::ref<RivReservoirViewPartMgr> m_geometry;
cvf::ref<RivReservoirPipesPartMgr> m_pipesPartManager;
};

View File

@ -38,7 +38,8 @@ RimResultDefinition::RimResultDefinition()
{
CAF_PDM_InitObject("Result Definition", "", "", "");
CAF_PDM_InitFieldNoDefault(&resultType, "ResultType", "Type", "", "", "");
CAF_PDM_InitFieldNoDefault(&resultType, "ResultType", "Type", "", "", "");
CAF_PDM_InitFieldNoDefault(&porosityModel, "PorosityModelType", "Type", "", "", "");
CAF_PDM_InitField(&resultVariable, "ResultVariable", RimDefines::undefinedResultName(), "Variable", "", "", "" );
resultVariable.setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
@ -58,6 +59,17 @@ RimResultDefinition::~RimResultDefinition()
void RimResultDefinition::setReservoirView(RimReservoirView* ownerReservoirView)
{
m_reservoirView = ownerReservoirView;
// TODO: This code is executed before reservoir is read, and then porosity model is never set to zero
if (m_reservoirView->eclipseCase() &&
m_reservoirView->eclipseCase()->reservoirData() &&
m_reservoirView->eclipseCase()->reservoirData()->mainGrid() )
{
if (m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->globalFractureModelActiveCellCount() == 0)
{
porosityModel.setUiHidden(true);
}
}
}
//--------------------------------------------------------------------------------------------------
@ -82,35 +94,6 @@ QList<caf::PdmOptionItemInfo> RimResultDefinition::calculateValueOptions(const c
{
if (m_reservoirView && m_reservoirView->gridCellResults())
{
/*
QStringList varList;
if (resultType() == RimDefines::DYNAMIC_NATIVE)
{
varList = readerInterface->dynamicResultNames();
if (!varList.contains("SOIL", Qt::CaseInsensitive))
{
// SOIL will be computed in RigReservoirCellResults::loadOrComputeSOIL() if SGAS and SWAT is present
if (varList.contains("SGAS", Qt::CaseInsensitive) && varList.contains("SWAT", Qt::CaseInsensitive))
{
varList.push_back("SOIL");
}
}
}
else if (resultType == RimDefines::STATIC_NATIVE)
{
varList = readerInterface->staticResultNames();
}
else if (resultType == RimDefines::GENERATED)
{
varList = m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->results()->resultNames(resultType());
}
else if (resultType == RimDefines::INPUT_PROPERTY)
{
varList = readerInterface->inputPropertyNames();
}
*/
QStringList varList = m_reservoirView->gridCellResults()->resultNames(resultType());
QList<caf::PdmOptionItemInfo> optionList;
int i;
@ -134,7 +117,7 @@ QList<caf::PdmOptionItemInfo> RimResultDefinition::calculateValueOptions(const c
//--------------------------------------------------------------------------------------------------
size_t RimResultDefinition::gridScalarIndex() const
{
if (m_gridScalarResultIndex == cvf::UNDEFINED_SIZE_T)
if (m_gridScalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
const RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults();
if (gridCellResults) m_gridScalarResultIndex = gridCellResults->findScalarResultIndex(resultType(), resultVariable());

View File

@ -42,8 +42,9 @@ public:
virtual void setReservoirView(RimReservoirView* ownerReservoirView);
RimReservoirView* reservoirView();
caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > resultType;
caf::PdmField<QString> resultVariable;
caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > resultType;
caf::PdmField< caf::AppEnum< RimDefines::PorosityModelType > > porosityModel;
caf::PdmField<QString> resultVariable;
void loadResult();
size_t gridScalarIndex() const;

View File

@ -25,6 +25,7 @@
#include "RifReaderMockModel.h"
#include "RifReaderEclipseInput.h"
#include "cafProgressInfo.h"
#include "RimProject.h"
CAF_PDM_SOURCE_INIT(RimResultReservoir, "EclipseCase");
@ -44,10 +45,10 @@ RimResultReservoir::RimResultReservoir()
//--------------------------------------------------------------------------------------------------
bool RimResultReservoir::openEclipseGridFile()
{
caf::ProgressInfo progInfo(20, "Reading Eclipse Grid File");
caf::ProgressInfo progInfo(50, "Reading Eclipse Grid File");
progInfo.setProgressDescription("Open Grid File");
progInfo.setNextProgressIncrement(19);
progInfo.setNextProgressIncrement(48);
// Early exit if reservoir data is created
if (m_rigReservoir.notNull()) return true;
@ -56,23 +57,38 @@ bool RimResultReservoir::openEclipseGridFile()
if (caseName().contains("Result Mock Debug Model"))
{
readerInterface = this->createMockModel(this->caseName());
size_t matrixActiveCellCount = 0;
size_t fractureActiveCellCount = 0;
for (size_t cellIdx = 0; cellIdx < m_rigReservoir->mainGrid()->cells().size(); cellIdx++)
{
const RigCell& cell = m_rigReservoir->mainGrid()->cells()[cellIdx];
if (cell.isActiveInMatrixModel())
{
matrixActiveCellCount++;
}
if (cell.isActiveInFractureModel())
{
fractureActiveCellCount++;
}
}
m_rigReservoir->mainGrid()->setGlobalMatrixModelActiveCellCount(matrixActiveCellCount);
m_rigReservoir->mainGrid()->setGlobalFractureModelActiveCellCount(fractureActiveCellCount);
m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
}
else
{
QString fullCaseName = caseName + ".EGRID";
QDir dir(caseDirectory.v());
if (!dir.exists(fullCaseName))
QString fname = createAbsoluteFilenameFromCase(caseName);
if (fname.isEmpty())
{
fullCaseName = caseName + ".GRID";
if (!dir.exists(fullCaseName))
{
return false;
}
return false;
}
QString fname = dir.absoluteFilePath(fullCaseName);
RigReservoir* reservoir = new RigReservoir;
readerInterface = new RifReaderEclipseOutput;
if (!readerInterface->open(fname, reservoir))
@ -84,15 +100,15 @@ bool RimResultReservoir::openEclipseGridFile()
m_rigReservoir = reservoir;
}
progInfo.setProgress(19);
progInfo.incrementProgress();
CVF_ASSERT(m_rigReservoir.notNull());
CVF_ASSERT(readerInterface.notNull());
m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p());
progInfo.setProgressDescription("Computing Faults");
m_rigReservoir->computeFaults();
progInfo.incrementProgress();
progInfo.setProgressDescription("Computing Cache");
m_rigReservoir->mainGrid()->computeCachedData();
@ -118,12 +134,12 @@ cvf::ref<RifReaderInterface> RimResultReservoir::createMockModel(QString modelNa
mockFileInterface->open("", reservoir.p());
{
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(1, 3, 4);
reservoir->mainGrid()->cell(idx).setActive(false);
reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
}
{
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(2, 2, 3);
reservoir->mainGrid()->cell(idx).setActive(false);
reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
}
}
else if (modelName == "Result Mock Debug Model With Results")
@ -190,3 +206,43 @@ QString RimResultReservoir::locationOnDisc() const
return caseDirectory;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimResultReservoir::createAbsoluteFilenameFromCase(const QString& caseName)
{
QString candidate;
candidate = QDir::fromNativeSeparators(caseDirectory.v() + QDir::separator() + caseName + ".EGRID");
if (QFile::exists(candidate)) return candidate;
candidate = QDir::fromNativeSeparators(caseDirectory.v() + QDir::separator() + caseName + ".GRID");
if (QFile::exists(candidate)) return candidate;
std::vector<caf::PdmObject*> parentObjects;
this->parentObjects(parentObjects);
QString projectPath;
for (size_t i = 0; i < parentObjects.size(); i++)
{
caf::PdmObject* obj = parentObjects[i];
RimProject* proj = dynamic_cast<RimProject*>(obj);
if (proj)
{
QFileInfo fi(proj->fileName);
projectPath = fi.path();
}
}
if (!projectPath.isEmpty())
{
candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + caseName + ".EGRID");
if (QFile::exists(candidate)) return candidate;
candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + caseName + ".GRID");
if (QFile::exists(candidate)) return candidate;
}
return QString();
}

View File

@ -53,4 +53,6 @@ public:
private:
cvf::ref<RifReaderInterface> createMockModel(QString modelName);
QString createAbsoluteFilenameFromCase(const QString& caseName);
};

View File

@ -328,7 +328,7 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd
RimReservoirView* insertedView = reservoirView->eclipseCase()->createAndAddReservoirView();
caf::PdmUiTreeItem* collectionItem = currentItem->parent();
size_t viewCount = rowCount(itemIndex.parent());
int viewCount = rowCount(itemIndex.parent());
beginInsertRows(itemIndex.parent(), viewCount, viewCount);
caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(collectionItem, viewCount, insertedView);

View File

@ -30,6 +30,7 @@
#include "RifEclipseInputFileTools.h"
#include "RimInputReservoir.h"
#include "RimBinaryExportSettings.h"
#include "RigReservoirCellResults.h"
//--------------------------------------------------------------------------------------------------
///
@ -727,7 +728,9 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty()
if (preferencesDialog.exec() == QDialog::Accepted)
{
size_t timeStep = resultSlot->reservoirView()->currentTimeStep();
bool isOk = RifEclipseInputFileTools::writeBinaryResultToTextFile(exportSettings.fileName, resultSlot->reservoirView()->eclipseCase()->reservoirData(), timeStep, resultSlot->resultVariable, exportSettings.eclipseKeyword, exportSettings.undefinedValue);
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(resultSlot->porosityModel());
bool isOk = RifEclipseInputFileTools::writeBinaryResultToTextFile(exportSettings.fileName, resultSlot->reservoirView()->eclipseCase()->reservoirData(), porosityModel, timeStep, resultSlot->resultVariable, exportSettings.eclipseKeyword, exportSettings.undefinedValue);
if (!isOk)
{
QMessageBox::critical(NULL, "File export", "Failed to exported current result to " + exportSettings.fileName);

View File

@ -118,7 +118,11 @@ void RimWell::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV
}
else if (&pipeRadiusScaleFactor == changedField)
{
if (m_reservoirView) m_reservoirView->createDisplayModelAndRedraw();
if (m_reservoirView)
{
m_reservoirView->schedulePipeGeometryRegen();
m_reservoirView->createDisplayModelAndRedraw();
}
}
}

View File

@ -22,11 +22,6 @@ include_directories(
${ResInsight_SOURCE_DIR}/cafProjectDataModel
${ResInsight_SOURCE_DIR}/CommonCode
${ResInsight_SOURCE_DIR}/ThirdParty/Ert/ecl/include
${ResInsight_SOURCE_DIR}/ThirdParty/Ert/util/include
${ResInsight_SOURCE_DIR}/ThirdParty/Ert/well/include
)
file( GLOB CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../*.cpp )
@ -41,6 +36,10 @@ set( LINK_LIBRARIES
LibGeometry
LibCore
ecl
ecl_well
ert_util
${QT_LIBRARIES}
)
@ -56,15 +55,12 @@ add_executable( ${ProjectName}
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set ( LINUX_LINK_LIBRARIES
${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert/lib/libecl.a
${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert/lib/libert_util.a
${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert/lib/libwell.a
lapack
pthread
)
# Linux specific code
set(CMAKE_CXX_FLAGS "-DCVF_LINUX -DUSE_ECL_LIB -pipe -Wextra -Woverloaded-virtual -Wformat")
set(CMAKE_CXX_FLAGS "-DCVF_LINUX -pipe -Wextra -Woverloaded-virtual -Wformat")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG -D_DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNO_DEBUG")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ")

View File

@ -34,16 +34,16 @@ TEST(RigReservoirTest, BasicTest)
QDateTime wellStartTime = QDateTime::currentDateTime();
size_t wellTimeStepCount = 5;
int wellTimeStepCount = 5;
wellCellTimeHistory->m_wellCellsTimeSteps.resize(wellTimeStepCount);
size_t i;
int i;
for (i = 0; i < wellTimeStepCount; i++)
{
wellCellTimeHistory->m_wellCellsTimeSteps[i].m_timestamp = QDateTime(wellStartTime).addYears(i);
}
size_t resultTimeStepCount = 2 * wellTimeStepCount;
int resultTimeStepCount = 2 * wellTimeStepCount;
QList<QDateTime> resultTimes;
for (i = 0; i < resultTimeStepCount; i++)
{

View File

@ -38,11 +38,12 @@ RigCell::RigCell() :
m_mainGridCellIndex(cvf::UNDEFINED_SIZE_T),
m_subGrid(NULL),
m_hostGrid(NULL),
m_isActive(true),
m_isInvalid(false),
m_isWellCell(false),
m_globalActiveIndex(cvf::UNDEFINED_SIZE_T),
m_cellIndex(cvf::UNDEFINED_SIZE_T)
m_activeIndexInMatrixModel(cvf::UNDEFINED_SIZE_T),
m_activeIndexInFractureModel(cvf::UNDEFINED_SIZE_T),
m_cellIndex(cvf::UNDEFINED_SIZE_T),
m_isInCoarseCell(false)
{
memcpy(m_cornerIndices.m_array, undefinedCornersArray, 8*sizeof(size_t));
@ -80,6 +81,145 @@ cvf::Vec3d RigCell::center() const
return avg;
}
bool isNear(const cvf::Vec3d& p1, const cvf::Vec3d& p2, double tolerance)
{
if ( cvf::Math::abs(p1[0] - p2[0]) < tolerance
&& cvf::Math::abs(p1[1] - p2[1]) < tolerance
&& cvf::Math::abs(p1[2] - p2[2]) < tolerance )
{
return true;
}
else
{
return false;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigCell::isLongPyramidCell(double maxHeightFactor, double nodeNearTolerance ) const
{
cvf::ubyte faceVertexIndices[4];
double squaredMaxHeightFactor = maxHeightFactor*maxHeightFactor;
const std::vector<cvf::Vec3d>& nodes = m_hostGrid->mainGrid()->nodes();
bool isPyramidCell = false;
int face;
for ( face = 0; face < 6 ; ++face)
{
cvf::StructGridInterface::cellFaceVertexIndices(static_cast<cvf::StructGridInterface::FaceType>(face), faceVertexIndices);
int zeroLengthEdgeCount = 0;
const cvf::Vec3d& c0 = nodes[m_cornerIndices[faceVertexIndices[0]]];
const cvf::Vec3d& c1 = nodes[m_cornerIndices[faceVertexIndices[1]]];
const cvf::Vec3d& c2 = nodes[m_cornerIndices[faceVertexIndices[2]]];
const cvf::Vec3d& c3 = nodes[m_cornerIndices[faceVertexIndices[3]]];
if (isNear(c0, c1, nodeNearTolerance)) { ++zeroLengthEdgeCount; }
if (isNear(c1, c2, nodeNearTolerance)) { ++zeroLengthEdgeCount; }
if (isNear(c2, c3, nodeNearTolerance)) { ++zeroLengthEdgeCount; }
if (zeroLengthEdgeCount == 3)
{
return true;
// Collapse of a complete face is detected. This is possibly the top of a pyramid
// "face" has the index to the collapsed face. We need the size of the opposite face
// to compare it with the pyramid "roof" length.
cvf::StructGridInterface::FaceType oppositeFace = cvf::StructGridInterface::POS_I;
switch (face)
{
case cvf::StructGridInterface::POS_I:
oppositeFace = cvf::StructGridInterface::NEG_I;
break;
case cvf::StructGridInterface::POS_J:
oppositeFace = cvf::StructGridInterface::NEG_J;
break;
case cvf::StructGridInterface::POS_K:
oppositeFace = cvf::StructGridInterface::NEG_K;
break;
case cvf::StructGridInterface::NEG_I:
oppositeFace = cvf::StructGridInterface::POS_I;
break;
case cvf::StructGridInterface::NEG_J:
oppositeFace = cvf::StructGridInterface::POS_J;
break;
case cvf::StructGridInterface::NEG_K:
oppositeFace = cvf::StructGridInterface::POS_K;
break;
default:
CVF_ASSERT(false);
break;
}
cvf::StructGridInterface::cellFaceVertexIndices(oppositeFace, faceVertexIndices);
const cvf::Vec3d& c0opp = nodes[m_cornerIndices[faceVertexIndices[0]]];
const cvf::Vec3d& c1opp = nodes[m_cornerIndices[faceVertexIndices[1]]];
const cvf::Vec3d& c2opp = nodes[m_cornerIndices[faceVertexIndices[2]]];
const cvf::Vec3d& c3opp = nodes[m_cornerIndices[faceVertexIndices[3]]];
// Check if any of the opposite face vertexes are also degenerated to the pyramid top
int okVertexCount = 0;
cvf::Vec3d okVxs[4];
if (!isNear(c0opp, c0, nodeNearTolerance)) { okVxs[okVertexCount] = c0opp; ++okVertexCount; }
if (!isNear(c1opp, c0, nodeNearTolerance)) { okVxs[okVertexCount] = c1opp; ++okVertexCount; }
if (!isNear(c2opp, c0, nodeNearTolerance)) { okVxs[okVertexCount] = c2opp; ++okVertexCount; }
if (!isNear(c3opp, c0, nodeNearTolerance)) { okVxs[okVertexCount] = c3opp; ++okVertexCount; }
if (okVertexCount < 2)
{
return true;
}
else
{
// Use the good vertices to calculate a face size that can be compared to the pyramid height:
double typicalSquaredEdgeLength = 0;
for (int i = 1; i < okVertexCount; ++i)
{
typicalSquaredEdgeLength += (okVxs[i-1] - okVxs[i]).lengthSquared();
}
typicalSquaredEdgeLength /= okVertexCount;
double pyramidHeightSquared = (okVxs[0] - c0).lengthSquared();
if (pyramidHeightSquared > squaredMaxHeightFactor*typicalSquaredEdgeLength)
{
return true;
}
}
}
// Check the ratio of the length of opposite edges.
// both ratios have to be above threshold to detect a pyramid-ish cell
// Only test this if we have all nonzero edge lenghts.
else if (zeroLengthEdgeCount == 0) // If the four first faces are ok, the two last must be as well
{
double e0SquareLenght = (c1 - c0).lengthSquared();
double e2SquareLenght = (c3 - c2).lengthSquared();
if ( e0SquareLenght / e2SquareLenght > squaredMaxHeightFactor
|| e2SquareLenght / e0SquareLenght > squaredMaxHeightFactor )
{
double e1SquareLenght = (c2 - c1).lengthSquared();
double e3SquareLenght = (c0 - c3).lengthSquared();
if ( e1SquareLenght / e3SquareLenght > squaredMaxHeightFactor
|| e3SquareLenght / e1SquareLenght > squaredMaxHeightFactor )
{
return true;
}
}
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -34,11 +34,16 @@ public:
RigCell();
~RigCell(); // Not virtual, to save space. Do not inherit from this class
caf::SizeTArray8& cornerIndices() { return m_cornerIndices;}
const caf::SizeTArray8& cornerIndices() const { return m_cornerIndices;}
caf::SizeTArray8& cornerIndices() { return m_cornerIndices;}
const caf::SizeTArray8& cornerIndices() const { return m_cornerIndices;}
bool active() const { return m_isActive; }
void setActive(bool val) { m_isActive = val; }
bool isActiveInMatrixModel() const { return m_activeIndexInMatrixModel != cvf::UNDEFINED_SIZE_T; }
size_t activeIndexInMatrixModel() const { return m_activeIndexInMatrixModel; }
void setActiveIndexInMatrixModel(size_t val) { m_activeIndexInMatrixModel = val; }
bool isActiveInFractureModel() const { return m_activeIndexInFractureModel != cvf::UNDEFINED_SIZE_T; }
size_t activeIndexInFractureModel() const { return m_activeIndexInFractureModel; }
void setActiveIndexInFractureModel(size_t val) { m_activeIndexInFractureModel = val; }
bool isInvalid() const { return m_isInvalid; }
void setInvalid( bool val ) { m_isInvalid = val; }
@ -49,8 +54,6 @@ public:
size_t cellIndex() const { return m_cellIndex; }
void setCellIndex(size_t val) { m_cellIndex = val; }
size_t globalActiveIndex() const { return m_globalActiveIndex; }
void setGlobalActiveIndex(size_t val) { m_globalActiveIndex = val; }
RigLocalGrid* subGrid() const { return m_subGrid; }
void setSubGrid(RigLocalGrid* subGrid) { m_subGrid = subGrid; }
@ -63,28 +66,34 @@ public:
size_t mainGridCellIndex() const { return m_mainGridCellIndex; }
void setMainGridCellIndex(size_t mainGridCellContainingThisCell) { m_mainGridCellIndex = mainGridCellContainingThisCell; }
bool isInCoarseCell() const { return m_isInCoarseCell; }
void setInCoarseCell(bool isInCoarseCell) { m_isInCoarseCell = isInCoarseCell; }
void setCellFaceFault(cvf::StructGridInterface::FaceType face) { m_cellFaceFaults[face] = true; }
bool isCellFaceFault(cvf::StructGridInterface::FaceType face) const { return m_cellFaceFaults[face]; }
cvf::Vec3d center() const;
cvf::Vec3d faceCenter(cvf::StructGridInterface::FaceType face) const;
bool firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersectionPoint) const;
bool isLongPyramidCell(double maxHeightFactor = 5, double nodeNearTolerance = 1e-3 ) const;
private:
caf::SizeTArray8 m_cornerIndices;
bool m_isActive;
bool m_isInvalid;
bool m_isWellCell;
size_t m_cellIndex; ///< This cells index in the grid it belongs to.
RigGridBase* m_hostGrid;
RigLocalGrid* m_subGrid;
size_t m_parentCellIndex; ///< Grid cell index of the cell in the parent grid containing this cell
size_t m_mainGridCellIndex;
bool m_isInCoarseCell;
bool m_cellFaceFaults[6];
RigGridBase* m_hostGrid;
size_t m_parentCellIndex; ///< Grid cell index of the cell in the parent grid containing this cell
size_t m_mainGridCellIndex;
// Result case specific data
bool m_isInvalid;
bool m_isWellCell;
size_t m_activeIndexInMatrixModel; ///< This cell's running index of all the active calls (matrix) in the reservoir
size_t m_activeIndexInFractureModel; ///< This cell's running index of all the active calls (fracture) in the reservoir
size_t m_globalActiveIndex; ///< This cell's running index of all the active calls in the reservoir. Used for result mapping
size_t m_cellIndex; ///< This cells index in the grid it belongs to.
};

View File

@ -21,6 +21,7 @@
#include "RigMainGrid.h"
#include "RigCell.h"
#include "RigReservoirCellResults.h"
#include "RigGridScalarDataAccess.h"
#include "cvfAssert.h"
@ -28,7 +29,9 @@
RigGridBase::RigGridBase(RigMainGrid* mainGrid):
m_gridPointDimensions(0,0,0),
m_mainGrid(mainGrid),
m_indexToStartOfCells(0)
m_indexToStartOfCells(0),
m_matrixModelActiveCellCount(cvf::UNDEFINED_SIZE_T),
m_fractureModelActiveCellCount(cvf::UNDEFINED_SIZE_T)
{
if (mainGrid == NULL)
{
@ -145,13 +148,6 @@ void RigGridBase::initSubCellsMainGridCellIndex()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigGridBase::scalarSetCount() const
{
return m_mainGrid->results()->resultCount();
}
//--------------------------------------------------------------------------------------------------
///
@ -219,49 +215,6 @@ size_t RigGridBase::gridPointIndexFromIJK(size_t i, size_t j, size_t k) const
return 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGridBase::cellCornerScalars(size_t timeStepIndex, size_t scalarSetIndex, size_t i, size_t j, size_t k, double scalars[8]) const
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigGridBase::vectorSetCount() const
{
return 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigGridBase::cellScalar(size_t timeStepIndex, size_t scalarSetIndex, size_t i, size_t j, size_t k) const
{
size_t cellIndex = cellIndexFromIJK(i, j, k);
return cellScalar(timeStepIndex, scalarSetIndex, cellIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigGridBase::cellScalar(size_t timeStepIndex, size_t scalarSetIndex, size_t cellIndex) const
{
size_t resultValueIndex = cellIndex;
bool useGlobalActiveIndex = m_mainGrid->results()->isUsingGlobalActiveIndex(scalarSetIndex);
if (useGlobalActiveIndex)
{
resultValueIndex = cell(cellIndex).globalActiveIndex();
if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL;
}
return m_mainGrid->results()->cellScalarResult(timeStepIndex, scalarSetIndex, resultValueIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -357,7 +310,7 @@ bool RigGridBase::isCellActive(size_t i, size_t j, size_t k) const
{
size_t idx = cellIndexFromIJK(i, j, k);
const RigCell& c = cell(idx);
if (!c.active() || c.isInvalid())
if (!c.isActiveInMatrixModel() || c.isInvalid())
{
return false;
}
@ -388,15 +341,6 @@ bool RigGridBase::cellIJKNeighbor(size_t i, size_t j, size_t k, FaceType face, s
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::Vec3d* RigGridBase::cellVector(size_t vectorSetIndex, size_t i, size_t j, size_t k) const
{
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -524,6 +468,54 @@ double RigGridBase::characteristicCellSize()
return characteristicCellSize;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigGridBase::matrixModelActiveCellCount() const
{
return m_matrixModelActiveCellCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigGridBase::fractureModelActiveCellCount() const
{
return m_fractureModelActiveCellCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigGridScalarDataAccess> RigGridBase::dataAccessObject(RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const
{
if (timeStepIndex != cvf::UNDEFINED_SIZE_T &&
scalarSetIndex != cvf::UNDEFINED_SIZE_T)
{
cvf::ref<RigGridScalarDataAccess> dataAccess = RigGridScalarDataAccess::createDataAccessObject(this, porosityModel, timeStepIndex, scalarSetIndex);
return dataAccess;
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGridBase::setFractureModelActiveCellCount(size_t activeFractureModelCellCount)
{
m_fractureModelActiveCellCount = activeFractureModelCellCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGridBase::setMatrixModelActiveCellCount(size_t activeMatrixModelCellCount)
{
m_matrixModelActiveCellCount = activeMatrixModelCellCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -27,10 +27,13 @@
#include <vector>
#include <string>
#include "cvfStructGridScalarDataAccess.h"
#include "RifReaderInterface.h"
class RigMainGrid;
class RigCell;
class RigGridScalarDataAccess;
class RigGridBase : public cvf::StructGridInterface
{
@ -58,6 +61,11 @@ public:
bool isMainGrid() const;
RigMainGrid* mainGrid() const { return m_mainGrid; }
size_t matrixModelActiveCellCount() const;
void setMatrixModelActiveCellCount(size_t activeMatrixModelCellCount);
size_t fractureModelActiveCellCount() const ;
void setFractureModelActiveCellCount(size_t activeFractureModelCellCount);
protected:
friend class RigMainGrid;//::initAllSubGridsParentGridPointer();
void initSubGridParentPointer();
@ -85,24 +93,22 @@ public:
virtual size_t gridPointIndexFromIJK( size_t i, size_t j, size_t k ) const;
virtual cvf::Vec3d gridPointCoordinate( size_t i, size_t j, size_t k ) const;
virtual size_t scalarSetCount() const;
virtual double cellScalar(size_t timeStepIndex, size_t scalarSetIndex, size_t i, size_t j, size_t k ) const;
virtual double cellScalar(size_t timeStepIndex, size_t scalarSetIndex, size_t cellIndex ) const;
virtual void cellCornerScalars(size_t timeStepIndex, size_t scalarSetIndex, size_t i, size_t j, size_t k, double scalars[8]) const;
virtual size_t vectorSetCount() const;
virtual const cvf::Vec3d* cellVector( size_t vectorSetIndex, size_t i, size_t j, size_t k ) const;
virtual bool isCellActive( size_t i, size_t j, size_t k ) const;
virtual bool isCellValid( size_t i, size_t j, size_t k ) const;
virtual bool cellIJKNeighbor(size_t i, size_t j, size_t k, FaceType face, size_t* neighborCellIndex ) const;
cvf::ref<RigGridScalarDataAccess> dataAccessObject(RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const;
private:
std::string m_gridName;
cvf::Vec3st m_gridPointDimensions;
size_t m_indexToStartOfCells; ///< Index into the global cell array stored in main-grid where this grids cells starts.
size_t m_gridIndex; ///< The LGR index of this grid. Starts with 1. Main grid has index 0.
RigMainGrid* m_mainGrid;
size_t m_matrixModelActiveCellCount;
size_t m_fractureModelActiveCellCount;
};

View File

@ -0,0 +1,131 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2012 Ceetron AS
//
// 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.
//
//##################################################################################################
#include "RigGridScalarDataAccess.h"
#include "cvfLibCore.h"
#include "cvfBase.h"
#include "cvfAssert.h"
#include "RigMainGrid.h"
#include "RigReservoirCellResults.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigGridScalarDataAccess::RigGridScalarDataAccess(const RigGridBase* grid, bool useGlobalActiveIndex, std::vector<double>* resultValues) :
m_grid(grid),
m_useGlobalActiveIndex(useGlobalActiveIndex),
m_resultValues(resultValues)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigGridScalarDataAccess> RigGridScalarDataAccess::createDataAccessObject(const RigGridBase* grid, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex)
{
CVF_ASSERT(grid);
CVF_ASSERT(grid->mainGrid());
CVF_ASSERT(grid->mainGrid()->results(porosityModel));
if (!grid || !grid->mainGrid() || !grid->mainGrid()->results(porosityModel))
{
return NULL;
}
bool useGlobalActiveIndex = grid->mainGrid()->results(porosityModel)->isUsingGlobalActiveIndex(scalarSetIndex);
std::vector< std::vector<double> > & scalarSetResults = grid->mainGrid()->results(porosityModel)->cellScalarResults(scalarSetIndex);
if (timeStepIndex >= scalarSetResults.size())
{
return NULL;
}
std::vector<double>* resultValues = &(scalarSetResults[timeStepIndex]);
cvf::ref<RigGridScalarDataAccess> object = new RigGridScalarDataAccess(grid, useGlobalActiveIndex, resultValues);
return object;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigGridScalarDataAccess::cellScalar(size_t i, size_t j, size_t k) const
{
size_t cellIndex = m_grid->cellIndexFromIJK(i, j, k);
return cellScalar(cellIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigGridScalarDataAccess::cellScalar(size_t cellIndex) const
{
if (m_resultValues->size() == 0 ) return HUGE_VAL;
size_t resultValueIndex = cellIndex;
if (m_useGlobalActiveIndex)
{
resultValueIndex = m_grid->cell(cellIndex).activeIndexInMatrixModel();
if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL;
}
if (m_resultValues->size() <= resultValueIndex) return HUGE_VAL;
return m_resultValues->at(resultValueIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigGridScalarDataAccess::gridPointScalar(size_t i, size_t j, size_t k) const
{
CVF_ASSERT(false);
return 0.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGridScalarDataAccess::cellCornerScalars(size_t i, size_t j, size_t k, double scalars[8]) const
{
CVF_ASSERT(false);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigGridScalarDataAccess::pointScalar(const cvf::Vec3d& p, double* scalarValue) const
{
CVF_ASSERT(false);
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::Vec3d* RigGridScalarDataAccess::cellVector(size_t i, size_t j, size_t k) const
{
CVF_ASSERT(false);
return new cvf::Vec3d();
}

View File

@ -0,0 +1,51 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2012 Ceetron AS
//
// 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.
//
//##################################################################################################
#pragma once
#include "cvfStructGridScalarDataAccess.h"
#include "RigGridBase.h"
#include "RifReaderInterface.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RigGridScalarDataAccess : public cvf::StructGridScalarDataAccess
{
private:
RigGridScalarDataAccess(const RigGridBase* grid, bool useGlobalActiveIndex, std::vector<double>* resultValues);
public:
static cvf::ref<RigGridScalarDataAccess> createDataAccessObject(const RigGridBase* grid, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex);
virtual double cellScalar(size_t i, size_t j, size_t k) const;
virtual double cellScalar(size_t cellIndex) const;
virtual void cellCornerScalars(size_t i, size_t j, size_t k, double scalars[8]) const;
virtual double gridPointScalar(size_t i, size_t j, size_t k) const;
virtual bool pointScalar(const cvf::Vec3d& p, double* scalarValue) const;
virtual const cvf::Vec3d* cellVector(size_t i, size_t j, size_t k) const;
private:
cvf::cref<RigGridBase> m_grid;
bool m_useGlobalActiveIndex;
std::vector<double>* m_resultValues;
};

View File

@ -29,9 +29,11 @@ RigMainGrid::RigMainGrid(void)
m_activeCellPositionMax(cvf::Vec3st::UNDEFINED),
m_validCellPositionMin(cvf::Vec3st::UNDEFINED),
m_validCellPositionMax(cvf::Vec3st::UNDEFINED),
m_activeCellCount(cvf::UNDEFINED_SIZE_T)
m_globalMatrixModelActiveCellCount(cvf::UNDEFINED_SIZE_T),
m_globalFractureModelActiveCellCount(cvf::UNDEFINED_SIZE_T)
{
m_results = new RigReservoirCellResults(this);
m_matrixModelResults = new RigReservoirCellResults(this);
m_fractureModelResults = new RigReservoirCellResults(this);
m_activeCellsBoundingBox.add(cvf::Vec3d::ZERO);
m_gridIndex = 0;
@ -79,35 +81,26 @@ void RigMainGrid::initAllSubCellsMainGridCellIndex()
}
//--------------------------------------------------------------------------------------------------
/// Calculates the number of active cells in the complete reservoir.
/// Caches the result, so subsequent calls are fast
///
//--------------------------------------------------------------------------------------------------
size_t RigMainGrid::numActiveCells()
size_t RigMainGrid::globalMatrixModelActiveCellCount() const
{
if (m_activeCellCount != cvf::UNDEFINED_SIZE_T) return m_activeCellCount;
return m_globalMatrixModelActiveCellCount;
if (m_cells.size() == 0) return 0;
size_t numActiveCells = 0;
size_t i;
for (i = 0; i < m_cells.size(); i++)
{
if (m_cells[i].active()) numActiveCells++;
}
m_activeCellCount = numActiveCells;
return m_activeCellCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigMainGrid::activeCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const
size_t RigMainGrid::globalFractureModelActiveCellCount() const
{
return m_globalFractureModelActiveCellCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigMainGrid::matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const
{
min = m_activeCellPositionMin;
max = m_activeCellPositionMax;
@ -116,7 +109,7 @@ void RigMainGrid::activeCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) con
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RigMainGrid::activeCellsBoundingBox() const
cvf::BoundingBox RigMainGrid::matrixModelActiveCellsBoundingBox() const
{
return m_activeCellsBoundingBox;
}
@ -183,7 +176,7 @@ void RigMainGrid::computeActiveAndValidCellRanges()
validBB.add(i, j, k);
}
if (c.active())
if (c.isActiveInMatrixModel())
{
activeBB.add(i, j, k);
}
@ -222,7 +215,7 @@ void RigMainGrid::computeBoundingBox()
for (i = 0; i < cellCount(); i++)
{
const RigCell& c = cell(i);
if (c.active())
if (c.isActiveInMatrixModel())
{
const caf::SizeTArray8& indices = c.cornerIndices();
@ -255,7 +248,7 @@ void RigMainGrid::computeCachedData()
///
///
//--------------------------------------------------------------------------------------------------
void RigMainGrid::calculateActiveCellInfo(std::vector<qint32> &gridNumber,
void RigMainGrid::calculateMatrixModelActiveCellInfo(std::vector<qint32> &gridNumber,
std::vector<qint32> &cellI,
std::vector<qint32> &cellJ,
std::vector<qint32> &cellK,
@ -264,7 +257,7 @@ void RigMainGrid::calculateActiveCellInfo(std::vector<qint32> &gridNumber,
std::vector<qint32> &hostCellJ,
std::vector<qint32> &hostCellK)
{
size_t numActiveCells = this->numActiveCells();
size_t numMatrixModelActiveCells = this->globalMatrixModelActiveCellCount();
gridNumber.clear();
cellI.clear();
@ -275,18 +268,18 @@ void RigMainGrid::calculateActiveCellInfo(std::vector<qint32> &gridNumber,
hostCellJ.clear();
hostCellK.clear();
gridNumber.reserve(numActiveCells);
cellI.reserve(numActiveCells);
cellJ.reserve(numActiveCells);
cellK.reserve(numActiveCells);
parentGridNumber.reserve(numActiveCells);
hostCellI.reserve(numActiveCells);
hostCellJ.reserve(numActiveCells);
hostCellK.reserve(numActiveCells);
gridNumber.reserve(numMatrixModelActiveCells);
cellI.reserve(numMatrixModelActiveCells);
cellJ.reserve(numMatrixModelActiveCells);
cellK.reserve(numMatrixModelActiveCells);
parentGridNumber.reserve(numMatrixModelActiveCells);
hostCellI.reserve(numMatrixModelActiveCells);
hostCellJ.reserve(numMatrixModelActiveCells);
hostCellK.reserve(numMatrixModelActiveCells);
for (size_t cIdx = 0; cIdx < m_cells.size(); ++cIdx)
{
if (m_cells[cIdx].active())
if (m_cells[cIdx].isActiveInMatrixModel())
{
RigGridBase* grid = m_cells[cIdx].hostGrid();
CVF_ASSERT(grid != NULL);
@ -313,14 +306,14 @@ void RigMainGrid::calculateActiveCellInfo(std::vector<qint32> &gridNumber,
parentGrid->ijkFromCellIndex(parentCellIdx, &pi, &pj, &pk);
}
gridNumber.push_back(grid->gridIndex());
cellI.push_back(i);
cellJ.push_back(j);
cellK.push_back(k);
parentGridNumber.push_back(parentGrid->gridIndex());
hostCellI.push_back(pi);
hostCellJ.push_back(pj);
hostCellK.push_back(pk);
gridNumber.push_back(static_cast<qint32>(grid->gridIndex()));
cellI.push_back(static_cast<qint32>(i));
cellJ.push_back(static_cast<qint32>(j));
cellK.push_back(static_cast<qint32>(k));
parentGridNumber.push_back(static_cast<qint32>(parentGrid->gridIndex()));
hostCellI.push_back(static_cast<qint32>(pi));
hostCellJ.push_back(static_cast<qint32>(pj));
hostCellK.push_back(static_cast<qint32>(pk));
}
}
}
@ -344,3 +337,30 @@ const RigGridBase* RigMainGrid::gridByIndex(size_t localGridIndex) const
CVF_ASSERT(localGridIndex - 1 < m_localGrids.size()) ;
return m_localGrids[localGridIndex-1].p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigReservoirCellResults* RigMainGrid::results(RifReaderInterface::PorosityModelResultType porosityModel)
{
if (porosityModel == RifReaderInterface::MATRIX_RESULTS)
{
return m_matrixModelResults.p();
}
return m_fractureModelResults.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigReservoirCellResults* RigMainGrid::results(RifReaderInterface::PorosityModelResultType porosityModel) const
{
if (porosityModel == RifReaderInterface::MATRIX_RESULTS)
{
return m_matrixModelResults.p();
}
return m_fractureModelResults.p();
}

View File

@ -23,11 +23,13 @@
#include "RigLocalGrid.h"
#include "cvfCollection.h"
#include "cvfBoundingBox.h"
#include "RifReaderInterface.h"
#include <QtGlobal>
class RigReservoirCellResults;
class RigMainGrid : public RigGridBase
class RigMainGrid : public RigGridBase
{
public:
RigMainGrid();
@ -40,11 +42,15 @@ public:
std::vector<RigCell>& cells() {return m_cells;}
const std::vector<RigCell>& cells() const {return m_cells;}
RigReservoirCellResults* results() {return m_results.p();}
const RigReservoirCellResults* results() const {return m_results.p();}
RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel);
const RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel) const;
size_t numActiveCells();
void activeCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const;
size_t globalMatrixModelActiveCellCount() const;
size_t globalFractureModelActiveCellCount() const;
void setGlobalMatrixModelActiveCellCount (size_t globalMatrixModelActiveCellCount) { m_globalMatrixModelActiveCellCount = globalMatrixModelActiveCellCount; }
void setGlobalFractureModelActiveCellCount(size_t globalFractureModelActiveCellCount) { m_globalFractureModelActiveCellCount = globalFractureModelActiveCellCount;}
void matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const;
void validCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const;
void addLocalGrid(RigLocalGrid* localGrid);
@ -52,7 +58,7 @@ public:
RigGridBase* gridByIndex(size_t localGridIndex);
const RigGridBase* gridByIndex(size_t localGridIndex) const;
void calculateActiveCellInfo(std::vector<qint32>& gridNumber,
void calculateMatrixModelActiveCellInfo(std::vector<qint32>& gridNumber,
std::vector<qint32>& i,
std::vector<qint32>& j,
std::vector<qint32>& k,
@ -62,7 +68,7 @@ public:
std::vector<qint32>& hostCellK);
void computeCachedData();
cvf::BoundingBox activeCellsBoundingBox() const;
cvf::BoundingBox matrixModelActiveCellsBoundingBox() const;
// Overrides
virtual cvf::Vec3d displayModelOffset() const;
@ -72,12 +78,17 @@ private:
void initAllSubCellsMainGridCellIndex();
void computeActiveAndValidCellRanges();
void computeBoundingBox();
private:
std::vector<cvf::Vec3d> m_nodes; ///< Global vertex table
std::vector<RigCell> m_cells; ///< Global array of all cells in the reservoir (including the ones in LGR's)
cvf::Collection<RigLocalGrid> m_localGrids; ///< List of all the LGR's in this reservoir
cvf::ref<RigReservoirCellResults> m_results;
size_t m_activeCellCount;
cvf::ref<RigReservoirCellResults> m_matrixModelResults;
cvf::ref<RigReservoirCellResults> m_fractureModelResults;
size_t m_globalMatrixModelActiveCellCount;
size_t m_globalFractureModelActiveCellCount;
cvf::Vec3st m_activeCellPositionMin;
cvf::Vec3st m_activeCellPositionMax;

View File

@ -134,6 +134,7 @@ void RigReservoirBuilderMock::appendCubeNodes(const cvf::Vec3d& min, const cvf::
//--------------------------------------------------------------------------------------------------
void RigReservoirBuilderMock::appendCells(size_t nodeStartIndex, size_t cellCount, RigGridBase* hostGrid, std::vector<RigCell>& cells)
{
size_t activeCellIndex = 0;
size_t i;
for (i = 0; i < cellCount; i++)
{
@ -152,7 +153,15 @@ void RigReservoirBuilderMock::appendCells(size_t nodeStartIndex, size_t cellCoun
riCell.cornerIndices()[7] = nodeStartIndex + i * 8 + 7;
riCell.setParentCellIndex(0);
if (!(i % 5)) riCell.setActive(false);
if (!(i % 5))
{
riCell.setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
}
else
{
riCell.setActiveIndexInMatrixModel(activeCellIndex++);
}
cells.push_back(riCell);
}
@ -269,7 +278,7 @@ bool RigReservoirBuilderMock::inputProperty(RigReservoir* reservoir, const QStri
/* generate secret number: */
int iSecret = rand() % 20 + 1;
for (k = 0; k < reservoir->mainGrid()->cellCount(); k++)
for (k = 0; k < reservoir->mainGrid()->cells().size(); k++)
{
values->push_back(k * iSecret);
}
@ -283,12 +292,11 @@ bool RigReservoirBuilderMock::inputProperty(RigReservoir* reservoir, const QStri
bool RigReservoirBuilderMock::staticResult(RigReservoir* reservoir, const QString& result, std::vector<double>* values)
{
size_t k;
size_t rIdx = 0;
for (k = 0; k < reservoir->mainGrid()->cells().size(); k++)
{
RigCell& cell = reservoir->mainGrid()->cells()[k];
if (cell.active())
if (cell.isActiveInMatrixModel())
{
if (cell.hostGrid() == reservoir->mainGrid())
{
@ -298,10 +306,6 @@ bool RigReservoirBuilderMock::staticResult(RigReservoir* reservoir, const QStrin
{
values->push_back(500);
}
cell.setGlobalActiveIndex(rIdx);
++rIdx;
}
}
@ -326,11 +330,10 @@ bool RigReservoirBuilderMock::dynamicResult(RigReservoir* reservoir, const QStri
double offsetValue = 100 * resultIndex;
size_t k;
size_t rIdx = 0;
for (k = 0; k < reservoir->mainGrid()->cells().size(); k++)
{
RigCell& cell = reservoir->mainGrid()->cells()[k];
if (cell.active())
if (cell.isActiveInMatrixModel())
{
if (cell.hostGrid() == reservoir->mainGrid())
{
@ -341,9 +344,6 @@ bool RigReservoirBuilderMock::dynamicResult(RigReservoir* reservoir, const QStri
{
values->push_back(500);
}
cell.setGlobalActiveIndex(rIdx);
++rIdx;
}
}

View File

@ -292,7 +292,7 @@ size_t RigReservoirCellResults::findOrLoadScalarResult(RimDefines::ResultCatType
for (i = 0; i < timeStepCount; i++)
{
std::vector<double>& values = m_cellScalarResults[resultGridIndex][i];
if (!m_readerInterface->dynamicResult(resultName, i, &values))
if (!m_readerInterface->dynamicResult(resultName, RifReaderInterface::MATRIX_RESULTS, i, &values))
{
resultLoadingSucess = false;
}
@ -303,7 +303,7 @@ size_t RigReservoirCellResults::findOrLoadScalarResult(RimDefines::ResultCatType
m_cellScalarResults[resultGridIndex].resize(1);
std::vector<double>& values = m_cellScalarResults[resultGridIndex][0];
if (!m_readerInterface->staticResult(resultName, &values))
if (!m_readerInterface->staticResult(resultName, RifReaderInterface::MATRIX_RESULTS, &values))
{
resultLoadingSucess = false;
}
@ -380,20 +380,8 @@ void RigReservoirCellResults::loadOrComputeSOIL()
if (soilResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
const std::vector< std::vector<double> >* swat = NULL;
const std::vector< std::vector<double> >* sgas = NULL;
size_t scalarIndexSWAT = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SWAT");
if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T)
{
swat = &(cellScalarResults(scalarIndexSWAT));
}
size_t scalarIndexSGAS = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SGAS");
if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T)
{
sgas = &(cellScalarResults(scalarIndexSGAS));
}
// Early exit if none of SWAT or SGAS is present
if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T)
@ -401,6 +389,20 @@ void RigReservoirCellResults::loadOrComputeSOIL()
return;
}
soilResultGridIndex = addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL");
const std::vector< std::vector<double> >* swat = NULL;
const std::vector< std::vector<double> >* sgas = NULL;
if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T)
{
swat = &(cellScalarResults(scalarIndexSWAT));
}
if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T)
{
sgas = &(cellScalarResults(scalarIndexSGAS));
}
size_t soilResultValueCount = 0;
size_t soilTimeStepCount = 0;
if (swat)
@ -417,7 +419,6 @@ void RigReservoirCellResults::loadOrComputeSOIL()
soilTimeStepCount = qMax(soilTimeStepCount, sgasTimeStepCount);
}
soilResultGridIndex = addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL");
m_cellScalarResults[soilResultGridIndex].resize(soilTimeStepCount);
std::vector< std::vector<double> >& soil = cellScalarResults(soilResultGridIndex);
@ -427,9 +428,8 @@ void RigReservoirCellResults::loadOrComputeSOIL()
{
soil[timeStepIdx].resize(soilResultValueCount);
int idx = 0;
#pragma omp parallel for
for (idx = 0; idx < static_cast<int>(soilResultValueCount); idx++)
for (int idx = 0; idx < static_cast<int>(soilResultValueCount); idx++)
{
double soilValue = 1.0;
if (sgas)
@ -512,14 +512,14 @@ void RigReservoirCellResults::computeDepthRelatedResults()
std::vector< std::vector<double> >& tops = cellScalarResults(topsResultGridIndex);
std::vector< std::vector<double> >& bottom = cellScalarResults(bottomResultGridIndex);
bool computeValuesForActiveCellsOnly = m_ownerMainGrid->numActiveCells() > 0;
bool computeValuesForActiveCellsOnly = m_ownerMainGrid->globalMatrixModelActiveCellCount() > 0;
size_t cellIdx = 0;
for (cellIdx = 0; cellIdx < m_ownerMainGrid->cells().size(); cellIdx++)
{
const RigCell& cell = m_ownerMainGrid->cells()[cellIdx];
if (computeValuesForActiveCellsOnly && !cell.active())
if (computeValuesForActiveCellsOnly && !cell.isActiveInMatrixModel())
{
continue;
}
@ -532,19 +532,19 @@ void RigReservoirCellResults::computeDepthRelatedResults()
if (computeDx)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_I) - cell.faceCenter(cvf::StructGridInterface::POS_I);
dx[0][cellIdx] = cellWidth.length();
dx[0][cellIdx] = cvf::Math::abs(cellWidth.x());
}
if (computeDy)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_J) - cell.faceCenter(cvf::StructGridInterface::POS_J);
dy[0][cellIdx] = cellWidth.length();
dy[0][cellIdx] = cvf::Math::abs(cellWidth.y());
}
if (computeDz)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_K) - cell.faceCenter(cvf::StructGridInterface::POS_K);
dz[0][cellIdx] = cellWidth.length();
dz[0][cellIdx] = cvf::Math::abs(cellWidth.z());
}
if (computeTops)
@ -651,8 +651,11 @@ bool RigReservoirCellResults::isUsingGlobalActiveIndex(size_t scalarResultIndex)
CVF_TIGHT_ASSERT(scalarResultIndex < m_cellScalarResults.size());
if (!m_cellScalarResults[scalarResultIndex].size()) return true;
if (m_cellScalarResults[scalarResultIndex][0].size() == m_ownerMainGrid->numActiveCells()) return true;
if (m_cellScalarResults[scalarResultIndex][0].size() == m_ownerMainGrid->cellCount()) return false;
size_t firstTimeStepResultValueCount = m_cellScalarResults[scalarResultIndex][0].size();
if (firstTimeStepResultValueCount == m_ownerMainGrid->globalMatrixModelActiveCellCount()) return true;
if (firstTimeStepResultValueCount == m_ownerMainGrid->globalFractureModelActiveCellCount()) return true;
if (firstTimeStepResultValueCount == m_ownerMainGrid->cells().size()) return false;
CVF_TIGHT_ASSERT(false); // Wrong number of results
@ -665,7 +668,7 @@ bool RigReservoirCellResults::isUsingGlobalActiveIndex(size_t scalarResultIndex)
QDateTime RigReservoirCellResults::timeStepDate(size_t scalarResultIndex, size_t timeStepIndex) const
{
if (scalarResultIndex < m_resultInfos.size() && (size_t)(m_resultInfos[scalarResultIndex].m_timeStepDates.size()) > timeStepIndex)
return m_resultInfos[scalarResultIndex].m_timeStepDates[timeStepIndex];
return m_resultInfos[scalarResultIndex].m_timeStepDates[static_cast<int>(timeStepIndex)];
else
return QDateTime();
}
@ -763,3 +766,13 @@ size_t RigReservoirCellResults::addStaticScalarResult(RimDefines::ResultCatType
return resultIdx;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderInterface::PorosityModelResultType RigReservoirCellResults::convertFromProjectModelPorosityModel(RimDefines::PorosityModelType porosityModel)
{
if (porosityModel == RimDefines::MATRIX_MODEL) return RifReaderInterface::MATRIX_RESULTS;
return RifReaderInterface::FRACTURE_RESULTS;
}

View File

@ -22,6 +22,7 @@
#include <QDateTime>
#include <vector>
#include <cmath>
#include "RifReaderInterface.h"
class RifReaderInterface;
class RigMainGrid;
@ -73,6 +74,8 @@ public:
std::vector< std::vector<double> > & cellScalarResults(size_t scalarResultIndex);
double cellScalarResult(size_t timeStepIndex, size_t scalarResultIndex, size_t resultValueIndex);
static RifReaderInterface::PorosityModelResultType convertFromProjectModelPorosityModel(RimDefines::PorosityModelType porosityModel);
private:
size_t addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, size_t resultValueCount);

View File

@ -281,18 +281,18 @@ void RiaSocketServer::readCommandFromOctave()
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
std::vector< std::vector<double> >* scalarResultFrames = NULL;
if (reservoir && reservoir->reservoirData() && reservoir->reservoirData()->mainGrid() && reservoir->reservoirData()->mainGrid()->results())
if (reservoir && reservoir->reservoirData() && reservoir->reservoirData()->mainGrid() && reservoir->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS))
{
scalarResultIndex = reservoir->reservoirData()->mainGrid()->results()->findOrLoadScalarResult(propertyName);
scalarResultIndex = reservoir->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(propertyName);
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T && isSetProperty)
{
scalarResultIndex = reservoir->reservoirData()->mainGrid()->results()->addEmptyScalarResult(RimDefines::GENERATED, propertyName);
scalarResultIndex = reservoir->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::GENERATED, propertyName);
}
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
{
scalarResultFrames = &(reservoir->reservoirData()->mainGrid()->results()->cellScalarResults(scalarResultIndex));
scalarResultFrames = &(reservoir->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(scalarResultIndex));
m_currentScalarIndex = scalarResultIndex;
m_currentPropertyName = propertyName;
}
@ -368,7 +368,7 @@ void RiaSocketServer::readCommandFromOctave()
return;
}
reservoir->reservoirData()->mainGrid()->calculateActiveCellInfo(activeCellInfo[0], activeCellInfo[1], activeCellInfo[2], activeCellInfo[3],
reservoir->reservoirData()->mainGrid()->calculateMatrixModelActiveCellInfo(activeCellInfo[0], activeCellInfo[1], activeCellInfo[2], activeCellInfo[3],
activeCellInfo[4], activeCellInfo[5], activeCellInfo[6], activeCellInfo[7]);
// First write timestep count
@ -441,7 +441,7 @@ void RiaSocketServer::readPropertyDataFromOctave()
size_t cellCountFromOctave = m_bytesPerTimeStepToRead / sizeof(double);
size_t gridActiveCellCount = m_currentReservoir->reservoirData()->mainGrid()->numActiveCells();
size_t gridActiveCellCount = m_currentReservoir->reservoirData()->mainGrid()->globalMatrixModelActiveCellCount();
size_t gridTotalCellCount = m_currentReservoir->reservoirData()->mainGrid()->cellCount();
if (cellCountFromOctave != gridActiveCellCount && cellCountFromOctave != gridTotalCellCount)
@ -518,9 +518,9 @@ void RiaSocketServer::readPropertyDataFromOctave()
if( m_currentScalarIndex != cvf::UNDEFINED_SIZE_T &&
m_currentReservoir->reservoirData() &&
m_currentReservoir->reservoirData()->mainGrid() &&
m_currentReservoir->reservoirData()->mainGrid()->results() )
m_currentReservoir->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS) )
{
m_currentReservoir->reservoirData()->mainGrid()->results()->recalculateMinMax(m_currentScalarIndex);
m_currentReservoir->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->recalculateMinMax(m_currentScalarIndex);
}
for (size_t i = 0; i < m_currentReservoir->reservoirViews.size(); ++i)

View File

@ -94,11 +94,6 @@ RIMainWindow::RIMainWindow()
slotRefreshFileActions();
slotRefreshEditActions();
#ifndef USE_ECL_LIB
// Always load mock model on Windows
//slotMockModel();
#endif
// Set pdm root so scripts are displayed
setPdmRoot(RIApplication::instance()->project());
}
@ -190,6 +185,10 @@ void RIMainWindow::createActions()
m_mockLargeResultsModelAction = new QAction("Large Mock Model", this);
m_mockInputModelAction = new QAction("Input Mock Model", this);
m_snapshotToFile = new QAction("Snapshot To File", this);
m_snapshotToClipboard = new QAction("Snapshot To Clipboard", this);
m_snapshotAllViewsToFile = new QAction("Snapshot All Views To File", this);
m_saveProjectAction = new QAction(QIcon(":/Save.png"), "&Save Project", this);
m_saveProjectAsAction = new QAction(QIcon(":/Save.png"), "Save Project &As", this);
@ -205,6 +204,10 @@ void RIMainWindow::createActions()
connect(m_mockResultsModelAction, SIGNAL(triggered()), SLOT(slotMockResultsModel()));
connect(m_mockLargeResultsModelAction, SIGNAL(triggered()), SLOT(slotMockLargeResultsModel()));
connect(m_mockInputModelAction, SIGNAL(triggered()), SLOT(slotInputMockModel()));
connect(m_snapshotToFile, SIGNAL(triggered()), SLOT(slotSnapshotToFile()));
connect(m_snapshotToClipboard, SIGNAL(triggered()), SLOT(slotSnapshotToClipboard()));
connect(m_snapshotAllViewsToFile, SIGNAL(triggered()), SLOT(slotSnapshotAllViewsToFile()));
connect(m_saveProjectAction, SIGNAL(triggered()), SLOT(slotSaveProject()));
connect(m_saveProjectAsAction, SIGNAL(triggered()), SLOT(slotSaveProjectAs()));
@ -303,6 +306,11 @@ void RIMainWindow::createMenus()
debugMenu->addAction(m_mockLargeResultsModelAction);
debugMenu->addAction(m_mockInputModelAction);
debugMenu->addSeparator();
debugMenu->addAction(m_snapshotToClipboard);
debugMenu->addAction(m_snapshotToFile);
debugMenu->addAction(m_snapshotAllViewsToFile);
connect(debugMenu, SIGNAL(aboutToShow()), SLOT(slotRefreshDebugActions()));
m_windowMenu = menuBar()->addMenu("&Windows");
@ -533,10 +541,24 @@ void RIMainWindow::refreshAnimationActions()
|| app->activeReservoirView()->wellCollection()->hasVisibleWellPipes())
{
QList<QDateTime> timeStepDates = app->activeReservoirView()->gridCellResults()->timeStepDates(0);
int i;
for (i = 0; i < timeStepDates.size(); i++)
bool showHoursAndMinutes = false;
for (int i = 0; i < timeStepDates.size(); i++)
{
timeStepStrings += timeStepDates[i].toString("dd.MMM yyyy");
if (timeStepDates[i].time().hour() != 0.0 || timeStepDates[i].time().minute() != 0.0)
{
showHoursAndMinutes = true;
}
}
QString formatString = "dd.MMM yyyy";
if (showHoursAndMinutes)
{
formatString += " - hh:mm";
}
for (int i = 0; i < timeStepDates.size(); i++)
{
timeStepStrings += timeStepDates[i].toString(formatString);
}
currentTimeStepIndex = RIApplication::instance()->activeReservoirView()->currentTimeStep();
}
@ -597,18 +619,11 @@ void RIMainWindow::slotOpenBinaryGridFiles()
{
RIApplication* app = RIApplication::instance();
#ifdef USE_ECL_LIB
QString defaultDir = app->defaultFileDialogDirectory("BINARY_GRID");
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Open Eclipse File", defaultDir, "Eclipse Grid Files (*.GRID *.EGRID)");
if (fileNames.size()) defaultDir = QFileInfo(fileNames.last()).absolutePath();
app->setDefaultFileDialogDirectory("BINARY_GRID", defaultDir);
#else
QStringList fileNames;
fileNames << "dummy";
#endif
int i;
for (i = 0; i < fileNames.size(); i++)
{
@ -1191,3 +1206,46 @@ void RIMainWindow::slotNewObjectPropertyView()
connect(treeView, SIGNAL(selectedObjectChanged( caf::PdmObject* )), propView, SLOT(showProperties( caf::PdmObject* )));
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIMainWindow::slotSnapshotToFile()
{
RIApplication* app = RIApplication::instance();
app->saveSnapshotPromtpForFilename();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIMainWindow::slotSnapshotToClipboard()
{
RIApplication* app = RIApplication::instance();
app->copySnapshotToClipboard();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIMainWindow::slotSnapshotAllViewsToFile()
{
RIApplication* app = RIApplication::instance();
app->saveSnapshotForAllViews("snapshots");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIMainWindow::hideAllDockWindows()
{
QList<QDockWidget*> dockWidgets = findChildren<QDockWidget*>();
for (int i = 0; i < dockWidgets.size(); i++)
{
dockWidgets[i]->close();
}
}

View File

@ -78,6 +78,8 @@ public:
RIProcessMonitor* processMonitor();
void hideAllDockWindows();
protected:
virtual void closeEvent(QCloseEvent* event);
@ -106,10 +108,6 @@ private:
QAction* m_openInputEclipseFileAction;
QAction* m_openProjectAction;
QAction* m_openLastUsedProjectAction;
QAction* m_mockModelAction;
QAction* m_mockResultsModelAction;
QAction* m_mockLargeResultsModelAction;
QAction* m_mockInputModelAction;
QAction* m_saveProjectAction;
QAction* m_saveProjectAsAction;
QAction* m_closeAction;
@ -117,6 +115,7 @@ private:
// Edit actions
QAction* m_editPreferences;
QAction* m_newPropertyView;
// View actions
QAction* m_viewFromNorth;
@ -127,8 +126,15 @@ private:
QAction* m_viewFromBelow;
QAction* m_zoomAll;
// Debug actions
QAction* m_newPropertyView;
// Mock actions
QAction* m_mockModelAction;
QAction* m_mockResultsModelAction;
QAction* m_mockLargeResultsModelAction;
QAction* m_mockInputModelAction;
QAction* m_snapshotToFile;
QAction* m_snapshotToClipboard;
QAction* m_snapshotAllViewsToFile;
// Help actions
QAction* m_aboutAction;
@ -158,12 +164,6 @@ private slots:
void slotOpenInputFiles();
void slotOpenProject();
void slotOpenLastUsedProject();
void slotMockModel();
void slotMockResultsModel();
void slotMockLargeResultsModel();
void slotInputMockModel();
void slotSaveProject();
void slotSaveProjectAs();
void slotCloseProject();
@ -173,6 +173,7 @@ private slots:
// Edit slots
void slotRefreshEditActions();
void slotEditPreferences();
void slotNewObjectPropertyView();
// View slots
void slotRefreshViewActions();
@ -188,7 +189,16 @@ private slots:
void slotRefreshDebugActions();
void slotUseShaders(bool enable);
void slotShowPerformanceInfo(bool enable);
void slotNewObjectPropertyView();
void slotSnapshotToFile();
void slotSnapshotToClipboard();
void slotSnapshotAllViewsToFile();
// Mock models
void slotMockModel();
void slotMockResultsModel();
void slotMockLargeResultsModel();
void slotInputMockModel();
// Windows slots
void slotBuildWindowActions();

View File

@ -282,6 +282,20 @@ void RIViewer::handlePickAction(int winPosX, int winPosY)
{
m_reservoirView->appendCellResultInfo(gridIndex, cellIndex, &resultInfo);
}
#if 0
const RigReservoir* reservoir = m_reservoirView->eclipseCase()->reservoirData();
const RigGridBase* grid = reservoir->grid(gridIndex);
const RigCell& cell = grid->cell(cellIndex);
const caf::SizeTArray8& cellNodeIndices = cell.cornerIndices();
const std::vector<cvf::Vec3d>& nodes = reservoir->mainGrid()->nodes();
for (int i = 0; i < 8; ++i)
{
resultInfo += QString::number(i) + " : ";
for (int j = 0; j < 3; ++j)
resultInfo += QString::number(nodes[cellNodeIndices[i]][j], 'g', 10) + " ";
resultInfo += "\n";
}
#endif
}
}
}
@ -433,7 +447,7 @@ void RIViewer::paintOverlayItems(QPainter* painter)
if (showAnimBar && m_showAnimProgress)
{
m_animationProgress->setMinimum(0);
m_animationProgress->setMaximum(frameCount() - 1);
m_animationProgress->setMaximum(static_cast<int>(frameCount()) - 1);
m_animationProgress->setValue(currentFrameIndex());
m_animationProgress->resize(columnWidth, m_animationProgress->sizeHint().height());

View File

@ -2,11 +2,14 @@
# Find the installation path. We assume that this script is placed in the installation directory.
INSTALL_PATH=$(dirname "$_")
#echo "Invoking ResInsight in path: $INSTALL_PATH"
# Store the users working directory
WORKING_DIR=`pwd`
# Change to application directory
cd "$INSTALL_PATH"
# Start the application
CmdName=ResInsight
exec ./$CmdName "$@"
# Start the application making the default file open path become the users cwd
CommandLine="./ResInsight -startdir $WORKING_DIR $@"
exec $CommandLine

View File

@ -17,29 +17,41 @@ endif()
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# Linux specific code
set(CMAKE_CXX_FLAGS "-DCVF_LINUX -DUSE_ECL_LIB -pipe -Wextra -Woverloaded-virtual -Wformat")
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 .")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g1")
ELSE()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp -DUSE_ECL_LIB")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
ENDIF()
################################################################################
# Defines
# Version number
################################################################################
set(CMAKE_MAJOR_VERSION 0)
set(CMAKE_MINOR_VERSION 9)
set(CMAKE_PATCH_VERSION 0)
set(PRODUCTVER ${CMAKE_MAJOR_VERSION},${CMAKE_MINOR_VERSION},0,${CMAKE_PATCH_VERSION})
set(STRPRODUCTVER ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION})
include (ResInsightVersion.cmake)
################################################################################
# ERT
################################################################################
add_subdirectory(ThirdParty/Ert/devel)
include_directories(
${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libecl/include/ert/ecl
${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libert_util/include/ert/util
${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libgeometry/include/ert/geometry
${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well
${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libecl/include
${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libert_util/include
${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libgeometry/include
${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libecl_well/include
${CMAKE_BINARY_DIR}/ThirdParty/Ert/devel/libert_util/include/ert/util
${CMAKE_BINARY_DIR}/ThirdParty/Ert/devel/libert_util/include
)
################################################################################
@ -148,4 +160,3 @@ if (NOT "${RESINSIGHT_PLATFORM}" STREQUAL "")
endif()
include (CPack)

View File

@ -486,7 +486,7 @@ ScalarMapperEffectGenerator::addAlphaAndUndefStripes(const cvf::TextureImage* te
modTexImg->allocate(texImg->width(), texImg->height() + 2);
modTexImg->fill(cvf::Color4ub(cvf::Color3ub(undefScalarColor), 255)); // Undefined color
for (size_t i = 0 ; i < texImg->width(); ++i)
for (cvf::uint i = 0 ; i < texImg->width(); ++i)
{
cvf::Color4ub legendColor = texImg->pixel(i, 0);
modTexImg->setPixel(i, 0, legendColor);

View File

@ -140,8 +140,8 @@ void QtMouseState::updateFromMouseEvent(QGraphicsSceneMouseEvent* event)
if (numMouseButtonsInState(m_mouseButtonState) == 1)
{
m_cleanButtonPressButton = buttonPressed;
m_cleanButtonPressPosX = event->scenePos().x();
m_cleanButtonPressPosY = event->scenePos().y();
m_cleanButtonPressPosX = (int)event->scenePos().x();
m_cleanButtonPressPosY = (int)event->scenePos().y();
}
}

View File

@ -21,9 +21,7 @@
#include "cvfObject.h"
#include "cvfVector3.h"
#include "cvfArray.h"
#include <vector>
namespace cvf {
@ -72,7 +70,6 @@ public:
virtual size_t cellIndexFromIJK(size_t i, size_t j, size_t k) const = 0;
virtual bool ijkFromCellIndex(size_t cellIndex, size_t* i, size_t* j, size_t* k) const = 0;
// Ta med toleranse?
virtual bool cellIJKFromCoordinate(const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k) const = 0;
virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d vertices[8]) const = 0;
@ -83,24 +80,6 @@ public:
virtual cvf::Vec3d gridPointCoordinate(size_t i, size_t j, size_t k) const = 0;
// Scalar results
virtual size_t scalarSetCount() const = 0;
virtual double cellScalar(size_t timeStepIndex, size_t scalarSetIndex, size_t i, size_t j, size_t k) const = 0;
virtual double cellScalar(size_t timeStepIndex, size_t scalarSetIndex, size_t cellIndex) const = 0;
virtual void cellCornerScalars(size_t timeStepIndex, size_t scalarSetIndex, size_t i, size_t j, size_t k, double scalars[8]) const = 0;
// Trenger vi denne? Kan erstattes av cellCornerScalars for kuttplan
double gridPointScalar(size_t scalarSetIndex, size_t i, size_t j, size_t k) const;
bool pointScalar(size_t scalarSetIndex, const cvf::Vec3d& p, double* scalarValue) const;
// Vector results
virtual size_t vectorSetCount() const = 0;
virtual const cvf::Vec3d* cellVector(size_t vectorSetIndex, size_t i, size_t j, size_t k) const = 0;
//void filteredCellCenterResultVectors(Vec3dArray& positions, Vec3dArray& resultVectors, const double minPositionDistance, const double resultVectorLengthThreshold) const;
//void filteredCellCenterResultVectors(Vec3dArray& positions, Vec3dArray& resultVectors, uint vectorSetIndex, uint stride, const double resultVectorLengthThreshold) const;
public:
static void cellFaceVertexIndices(FaceType face, cvf::ubyte vertexIndices[4]);
static FaceType oppositeFace(FaceType face);

View File

@ -18,8 +18,11 @@
//##################################################################################################
#include "cvfBase.h"
#include "cvfStructGrid.h"
#include "cvfStructGridGeometryGenerator.h"
#include "cvfStructGridScalarDataAccess.h"
#include "cvfDebugTimer.h"
#include "cvfGeometryBuilderDrawableGeo.h"
#include "cvfPrimitiveSetIndexedUInt.h"
@ -255,7 +258,7 @@ ref<UIntArray> StructGridGeometryGenerator::lineIndicesFromQuadVertexArray(const
CVF_ASSERT(vertexArray);
size_t numVertices = vertexArray->size();
int numQuads = numVertices/4;
int numQuads = static_cast<int>(numVertices/4);
CVF_ASSERT(numVertices%4 == 0);
ref<UIntArray> indices = new UIntArray;
@ -385,8 +388,10 @@ void StructGridGeometryGenerator::computeArrays()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridGeometryGenerator::textureCoordinates(Vec2fArray* textureCoords, size_t timeStepIndex, size_t scalarSetIndex, const ScalarMapper* mapper) const
void StructGridGeometryGenerator::textureCoordinates(Vec2fArray* textureCoords, const StructGridScalarDataAccess* dataAccessObject, const ScalarMapper* mapper) const
{
if (!dataAccessObject) return;
size_t numVertices = m_quadsToGridCells.size()*4;
textureCoords->resize(numVertices);
@ -398,7 +403,7 @@ void StructGridGeometryGenerator::textureCoordinates(Vec2fArray* textureCoords,
#pragma omp parallel for private(texCoord, cellScalarValue)
for (int i = 0; i < static_cast<int>(m_quadsToGridCells.size()); i++)
{
cellScalarValue = m_grid->cellScalar(timeStepIndex, scalarSetIndex, m_quadsToGridCells[i]);
cellScalarValue = dataAccessObject->cellScalar(m_quadsToGridCells[i]);
texCoord = mapper->mapToTextureCoord(cellScalarValue);
if (cellScalarValue == HUGE_VAL || cellScalarValue != cellScalarValue) // a != a is true for NAN's
{

View File

@ -28,7 +28,7 @@ namespace cvf {
class DrawableGeo;
class ScalarMapper;
class StructGridScalarDataAccess;
//--------------------------------------------------------------------------------------------------
///
@ -129,7 +129,7 @@ public:
const StructGridInterface* activeGrid() { return m_grid.p(); }
void textureCoordinates(Vec2fArray* textureCoords, size_t timeStepIndex, size_t scalarSetIndex, const ScalarMapper* mapper) const;
void textureCoordinates(Vec2fArray* textureCoords, const StructGridScalarDataAccess* dataAccessObject, const ScalarMapper* mapper) const;
// Mapping between cells and geometry
ref<cvf::Array<size_t> >

View File

@ -0,0 +1,46 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2012 Ceetron AS
//
// 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.
//
//##################################################################################################
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
namespace cvf {
class StructGridScalarDataAccess : public Object
{
public:
virtual double cellScalar(size_t i, size_t j, size_t k) const = 0;
virtual double cellScalar(size_t cellIndex) const = 0;
virtual void cellCornerScalars(size_t i, size_t j, size_t k, double scalars[8]) const = 0;
// Trenger vi denne? Kan erstattes av cellCornerScalars for kuttplan
virtual double gridPointScalar(size_t i, size_t j, size_t k) const = 0;
virtual bool pointScalar(const cvf::Vec3d& p, double* scalarValue) const = 0;
// Vector results
virtual const cvf::Vec3d* cellVector(size_t i, size_t j, size_t k) const = 0;
};
} // namespace cvf

View File

@ -98,6 +98,8 @@ else()
"${CMAKE_CURRENT_BINARY_DIR}/riSetActiveCellProperty.oct"
"${CMAKE_CURRENT_BINARY_DIR}/riGetActiveCellInfo.oct"
"${CMAKE_CURRENT_BINARY_DIR}/riGetMainGridDimensions.oct"
SOURCES ${CPP_SOURCES}
)
endif()

View File

@ -0,0 +1,147 @@
Considerations
==================================
This function interface towards ResInsight is currently a Draft,
and not addressing some issues. The known issues are :
1. How do we address Cases in the future when we have Case Groups ?
Where do we write/store the generated data ?
2. Users wants to run octave operations on several cases/groups.
There are two ways (at least) of doing that. Either from ResInsight:
1 Command to call a specified Octave Script for each selected Case
2 Creating Scripts that loops over all selections in ResInsight
Option 2 is needed if users wants to do cross-case operations
Option 1 seems intuitive for one case operations
How does these two relate ?
3. Do we need functions to retreive the selected/active cases/groups ?
4. Do we need functions to retreive info on what Parent cells an LGR occupies ?
Project Information
==================================
Vector[Casenames] riGetCaseNames()
Returns a vector of all the case names in the current ResInsight project
Use this to determine the number of cases as well
This probably needs some additions related to Case Groups
Retreiving Grid Metadata
==================================
Matrix[ActiveCells][8] riGetActiveCellInfo( [CaseName/CaseIndex])
Returns a two dimensional matrix: [ActiveCells][8]
Containing grid and ijk information about the cells from the Eclipse Case defined.
The columns contain the following information:
1: GridIndex: The index of the grid the cell resides in. (Main grid has index 0)
2, 3, 4: I, J, K: 1-based index address of the cell in the grid.
5: ParentGridIndex. The index to the grid that this cell's grid is residing in.
6, 7, 8: PI, PJ, PK address of the parent grid cell that this cell is a part of.
If the Eclipse Case is not defined, the active View in ResInsight is used.
Matrix[g0I, g0J, g0K; ... ; gnI, gnJ, gnK] riGetGridDimensions ( [CaseName/CaseIndex])
Returns a matrix: [NuberOfGrids][3]
containing the I, J, K dimensions of the main grid and all the LGR's
# Unnecessary ? # Vector(3)[ICount, JCount, KCount] riGetMainGridDimensions( [CaseName/CaseIndex])
# Unnecessary ? #
# Unnecessary ? # Returns a vector of size 3: [ICount, JCount, KCount]
# Unnecessary ? # Containing the dimensions of the main grid in the requested case.
# Unnecessary ? # If the Eclipse Case is not defined, the active View in ResInsight is used."
# Unnecessary ? #
# Unnecessary ? # NumberOfGrids riGetNumLGRs([Casename/CaseIndex])
# Unnecessary ? #
# Unnecessary ? # Returns an integer telling the number of LGRS in this case
Vector[Dates] riGetTimestepDates([Casename/CaseIndex])
Returns a vector of all the timesteps in a case as dates YYYY.MM.DD
Vector[Days] riGetTimestepDays([Casename/CaseIndex])
Returns a vector of all the timesteps in a case as days from start
Retreiving property data
==================================
Matrix[ActiveCells][Timesteps] riGetActiveCellProperty( [CaseName/CaseIndex], PropertyName )
Returns a two dimentional matrix: [ActiveCells][Timesteps]
Containing the requested property data from the Eclipse Case defined.
If the Eclipse Case is not defined, the active View in ResInsight is used.
Matrix[numI][numJ][numK][timeSteps] riGetGridProperty( [Casename/CaseIndex], GridIndex , PropertyName )
Matrix[numI][numJ][numK] riGetGridProperty( [Casename/CaseIndex], GridIndex , PropertyName, TimeStep )
Returns a 4D or 3D matrix of the requested property data for all the gridcells in the requested grid.
Grids are indexed from 0 - main grid to Max num LGR's
Writing Back to ResInsight
==================================
riSetActiveCellProperty( Matrix(nActiveCells, nTimesteps), [CaseName/CaseIndex], PropertyName )
Interprets the supplied matrix as an eclipse property set, and puts the data into
ResInsight as a "Generated" property with the name "PropertyName". The property
is added to the active case if no case specification is given, or to the Eclipse Case
named "CaseName" or to the case number "CaseIndex". "
riSetGridProperty( Matrix[numI][numJ][numK][timeSteps] , [CaseName/CaseIndex], GridIndex, PropertyName )
riSetGridProperty( Matrix[numI][numJ][numK], [CaseName/CaseIndex], GridIndex, PropertyName , TimeStep)
Interprets the supplied matrix as an eclipse 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". The property
is added to the active case if no case specification is given, or to the Eclipse Case
named "CaseName" or to the case number "CaseIndex". "
Cell geometry functions:
=================================
Matrix[numI*Vector(3)][numJ*Vec(3)] [numK*Vec(3)] riGetCellCenters( [Casename/CaseIndex], GridIndex )
Returns the UTM coordinates (X, Y, Z) for centerpoint of all cells
Matrix[numI*8*Vector(3)][numJ*8*Vec(3)] [numK*8*Vec(3)] riGetCellCorners( [Casename/CaseIndex], GridIndex )
Returns the UTM coordinates of the each cells 8 corners
Well data functions
=================================
Vector[WellNames] riGetWellNames([Casename/CaseIndex])
Returns the names of all the wells in the case
Vector[ I, J, K, GridNr] riGetWellCells([Casename/CaseIndex], WellName/WellIndex, TimeStep, Producing/Injecting/Any)
Returns the cells that has the requested production status for the given well and timestep
Comments to remember/consider
=================================
“Execute for all cases within group” in script-tree
Well trajectories (alternative trajectory like Planned / Drilled /Real Time/ Project ahead?)
riGetTrajectories(well, case) ? MD, Inc, Az, Norht(X), East(Y), TVD(Z),DLS,BUR,TR,prop/log/connections?
Operator to restrict operation to be carried out inside a given polygon object
riInside(polygon)
Set Octave function Case ID as a function parameter (enable for loops)
Write grid data to file on .grdecl format (and read & append?)

8
ResInsightVersion.cmake Normal file
View File

@ -0,0 +1,8 @@
set(CMAKE_MAJOR_VERSION 0)
set(CMAKE_MINOR_VERSION 9)
set(CMAKE_PATCH_VERSION 2)
set(PRODUCTVER ${CMAKE_MAJOR_VERSION},${CMAKE_MINOR_VERSION},0,${CMAKE_PATCH_VERSION})
set(STRPRODUCTVER ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION})

View File

@ -1,117 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'vector_template.h' 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.
*/
#ifndef __bool_VECTOR_H__
#define __bool_VECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <buffer.h>
#include <type_macros.h>
typedef struct bool_vector_struct bool_vector_type;
typedef bool (bool_ftype) (bool);
int bool_vector_lookup_bin( const bool_vector_type * limits , bool value , int guess);
int bool_vector_lookup_bin__( const bool_vector_type * limits , bool value , int guess);
void bool_vector_inplace_div( bool_vector_type * vector , const bool_vector_type * inv_factor);
void bool_vector_inplace_mul( bool_vector_type * vector , const bool_vector_type * factor);
void bool_vector_inplace_add( bool_vector_type * vector , const bool_vector_type * delta);
void bool_vector_set_read_only( bool_vector_type * vector , bool read_only);
bool bool_vector_get_read_only( const bool_vector_type * vector );
void bool_vector_resize( bool_vector_type * vector , int new_alloc_size );
void bool_vector_memcpy_data( bool * target, const bool_vector_type * src );
void bool_vector_memcpy( bool_vector_type * target , const bool_vector_type * src);
void bool_vector_memcpy_data_block( bool_vector_type * target , const bool_vector_type * src , int target_offset , int src_offset , int len);
bool bool_vector_growable( const bool_vector_type * vector);
void bool_vector_select_unique(bool_vector_type * vector);
bool_vector_type * bool_vector_alloc( int init_size , bool );
bool_vector_type * bool_vector_alloc_private_wrapper(int init_size, bool default_value , bool * data , int alloc_size);
bool_vector_type * bool_vector_alloc_shared_wrapper(int init_size, bool default_value , bool * data , int alloc_size);
bool_vector_type * bool_vector_alloc_strided_copy( const bool_vector_type * src , int start , int stop , int stride );
bool_vector_type * bool_vector_alloc_copy( const bool_vector_type * src);
void bool_vector_imul(bool_vector_type * vector, int index, bool factor);
void bool_vector_scale(bool_vector_type * vector, bool factor);
bool bool_vector_iget(const bool_vector_type * , int);
bool bool_vector_safe_iget(const bool_vector_type * , int);
bool bool_vector_get_min(const bool_vector_type * vector);
bool bool_vector_get_max(const bool_vector_type * vector);
int bool_vector_get_min_index(const bool_vector_type * vector, bool reverse);
int bool_vector_get_max_index(const bool_vector_type * vector, bool reverse);
bool bool_vector_iadd( bool_vector_type * vector , int index , bool delta);
void bool_vector_iset(bool_vector_type * , int , bool);
void bool_vector_idel_block( bool_vector_type * vector , int index , int block_size);
bool bool_vector_idel( bool_vector_type * vector , int index);
void bool_vector_append(bool_vector_type * , bool);
void bool_vector_free(bool_vector_type *);
void bool_vector_free__(void *);
void bool_vector_free_data(bool_vector_type *);
void bool_vector_reset(bool_vector_type *);
void bool_vector_reset__(void * __vector);
int bool_vector_size(const bool_vector_type * );
bool bool_vector_pop(bool_vector_type * vector);
bool bool_vector_get_first(const bool_vector_type * vector);
bool bool_vector_get_last(const bool_vector_type * );
bool * bool_vector_get_ptr(const bool_vector_type * );
bool * bool_vector_alloc_data_copy( const bool_vector_type * vector );
const bool * bool_vector_get_const_ptr(const bool_vector_type * );
void bool_vector_set_many(bool_vector_type * , int , const bool * , int );
void bool_vector_set_all(bool_vector_type * vector , bool value);
void bool_vector_append_many(bool_vector_type * vector , const bool * data , int length);
void bool_vector_shrink(bool_vector_type * );
bool bool_vector_sum(const bool_vector_type * );
bool bool_vector_get_default(const bool_vector_type * );
void bool_vector_set_default(bool_vector_type * vector, bool default_value);
void bool_vector_append_default(bool_vector_type * vector , bool default_value);
void bool_vector_iset_default(bool_vector_type * vector , int index , bool default_value);
bool bool_vector_is_sorted( const bool_vector_type * vector , bool reverse);
int bool_vector_index(const bool_vector_type * vector , bool value);
int bool_vector_index_sorted(const bool_vector_type * vector , bool value);
void bool_vector_sort(bool_vector_type * vector);
void bool_vector_rsort(bool_vector_type * vector);
void bool_vector_permute(bool_vector_type * vector , const int * perm);
int * bool_vector_alloc_sort_perm(const bool_vector_type * vector);
int * bool_vector_alloc_rsort_perm(const bool_vector_type * vector);
void bool_vector_fprintf(const bool_vector_type * vector , FILE * stream , const char * name , const char * fmt);
void bool_vector_fwrite(const bool_vector_type * vector , FILE * stream);
void bool_vector_buffer_fread(bool_vector_type * vector , buffer_type * buffer);
bool_vector_type * bool_vector_fread_alloc( FILE * stream );
bool_vector_type * bool_vector_buffer_fread_alloc( buffer_type * buffer );
void bool_vector_buffer_fwrite(const bool_vector_type * vector , buffer_type * buffer);
void bool_vector_fread( bool_vector_type * vector , FILE * stream );
void bool_vector_fwrite_data( const bool_vector_type * vector , FILE * stream );
void bool_vector_fread_data( bool_vector_type * vector , int size, FILE * stream);
bool bool_vector_equal(const bool_vector_type * vector1 , const bool_vector_type * vector2);
void bool_vector_apply(bool_vector_type * vector , bool_ftype *func);
int bool_vector_count_equal( const bool_vector_type * vector , bool cmp_value);
int bool_vector_element_size( const bool_vector_type * vector );
UTIL_SAFE_CAST_HEADER( bool_vector );
#ifdef __cplusplus
}
#endif
#endif
//

View File

@ -1,103 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'buffer.h' 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.
*/
#ifndef __BUFFER_H__
#define __BUFFER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <time.h>
#include <ssize_t.h>
typedef struct buffer_struct buffer_type;
buffer_type * buffer_alloc( size_t buffer_size );
buffer_type * buffer_alloc_private_wrapper(void * data , size_t buffer_size );
bool buffer_search_replace( buffer_type * buffer , const char * old_string , const char * new_string);
void buffer_shrink_to_fit( buffer_type * buffer );
void buffer_memshift(buffer_type * buffer , size_t offset, ssize_t shift);
bool buffer_strstr( buffer_type * buffer , const char * expr );
bool buffer_strchr( buffer_type * buffer , int c);
void buffer_replace_string( buffer_type * buffer , size_t offset , size_t old_size , const char * new_string);
void buffer_replace_data(buffer_type * buffer , size_t offset , size_t old_size , const void * new_data , size_t new_size);
void buffer_free_container( buffer_type * buffer );
void buffer_free( buffer_type * buffer);
size_t buffer_safe_fread(buffer_type * buffer , void * target_ptr , size_t item_size , size_t items);
size_t buffer_fread(buffer_type * buffer , void * target_ptr , size_t item_size , size_t items);
size_t buffer_safe_fwrite(buffer_type * buffer , const void * src_ptr , size_t item_size , size_t items);
size_t buffer_fwrite(buffer_type * buffer , const void * src_ptr , size_t item_size , size_t items);
const char * buffer_fread_string(buffer_type * buffer);
char * buffer_fread_alloc_string(buffer_type * buffer);
void buffer_fwrite_string(buffer_type * buffer , const char * string);
void buffer_summarize(const buffer_type * buffer , const char *);
void buffer_fwrite_char_ptr(buffer_type * buffer , const char * string_ptr );
void buffer_terminate_char_ptr( buffer_type * buffer );
void buffer_fwrite_char(buffer_type * buffer , char value);
void buffer_fwrite_int(buffer_type * buffer , int value);
void buffer_fskip_bool(buffer_type * buffer);
void buffer_fwrite_bool(buffer_type * buffer , bool value);
int buffer_fread_int(buffer_type * buffer );
bool buffer_fread_bool(buffer_type * buffer);
long int buffer_fread_long(buffer_type * buffer);
void buffer_fskip_long(buffer_type * buffer);
void buffer_store(const buffer_type * buffer , const char * filename);
size_t buffer_get_offset(const buffer_type * buffer);
size_t buffer_get_alloc_size(const buffer_type * buffer);
size_t buffer_get_size(const buffer_type * buffer);
size_t buffer_get_string_size( const buffer_type * buffer );
size_t buffer_get_remaining_size(const buffer_type * buffer);
void * buffer_get_data(const buffer_type * buffer);
void * buffer_alloc_data_copy(const buffer_type * buffer);
void buffer_stream_fwrite( const buffer_type * buffer , FILE * stream );
int buffer_fgetc( buffer_type * buffer );
void buffer_fseek(buffer_type * buffer , ssize_t offset , int whence);
void buffer_fskip(buffer_type * buffer, ssize_t offset);
void buffer_clear( buffer_type * buffer );
void buffer_fskip_int(buffer_type * buffer);
void buffer_fskip_time_t(buffer_type * buffer);
time_t buffer_fread_time_t(buffer_type * buffer);
void buffer_fwrite_time_t(buffer_type * buffer , time_t value);
void buffer_rewind(buffer_type * buffer );
double buffer_fread_double(buffer_type * buffer);
void buffer_fwrite_double(buffer_type * buffer , double value);
size_t buffer_stream_fwrite_n( const buffer_type * buffer , size_t offset , ssize_t write_size , FILE * stream );
void buffer_stream_fprintf( const buffer_type * buffer , FILE * stream );
void buffer_stream_fread( buffer_type * buffer , size_t byte_size , FILE * stream);
buffer_type * buffer_fread_alloc(const char * filename);
void buffer_fread_realloc(buffer_type * buffer , const char * filename);
#ifdef WITH_ZLIB
size_t buffer_fwrite_compressed(buffer_type * buffer, const void * ptr , size_t byte_size);
size_t buffer_fread_compressed(buffer_type * buffer , size_t compressed_size , void * target_ptr , size_t target_size);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,117 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'vector_template.h' 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.
*/
#ifndef __double_VECTOR_H__
#define __double_VECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <buffer.h>
#include <type_macros.h>
typedef struct double_vector_struct double_vector_type;
typedef double (double_ftype) (double);
int double_vector_lookup_bin( const double_vector_type * limits , double value , int guess);
int double_vector_lookup_bin__( const double_vector_type * limits , double value , int guess);
void double_vector_inplace_div( double_vector_type * vector , const double_vector_type * inv_factor);
void double_vector_inplace_mul( double_vector_type * vector , const double_vector_type * factor);
void double_vector_inplace_add( double_vector_type * vector , const double_vector_type * delta);
void double_vector_set_read_only( double_vector_type * vector , bool read_only);
bool double_vector_get_read_only( const double_vector_type * vector );
void double_vector_resize( double_vector_type * vector , int new_alloc_size );
void double_vector_memcpy_data( double * target, const double_vector_type * src );
void double_vector_memcpy( double_vector_type * target , const double_vector_type * src);
void double_vector_memcpy_data_block( double_vector_type * target , const double_vector_type * src , int target_offset , int src_offset , int len);
bool double_vector_growable( const double_vector_type * vector);
void double_vector_select_unique(double_vector_type * vector);
double_vector_type * double_vector_alloc( int init_size , double );
double_vector_type * double_vector_alloc_private_wrapper(int init_size, double default_value , double * data , int alloc_size);
double_vector_type * double_vector_alloc_shared_wrapper(int init_size, double default_value , double * data , int alloc_size);
double_vector_type * double_vector_alloc_strided_copy( const double_vector_type * src , int start , int stop , int stride );
double_vector_type * double_vector_alloc_copy( const double_vector_type * src);
void double_vector_imul(double_vector_type * vector, int index, double factor);
void double_vector_scale(double_vector_type * vector, double factor);
double double_vector_iget(const double_vector_type * , int);
double double_vector_safe_iget(const double_vector_type * , int);
double double_vector_get_min(const double_vector_type * vector);
double double_vector_get_max(const double_vector_type * vector);
int double_vector_get_min_index(const double_vector_type * vector, bool reverse);
int double_vector_get_max_index(const double_vector_type * vector, bool reverse);
double double_vector_iadd( double_vector_type * vector , int index , double delta);
void double_vector_iset(double_vector_type * , int , double);
void double_vector_idel_block( double_vector_type * vector , int index , int block_size);
double double_vector_idel( double_vector_type * vector , int index);
void double_vector_append(double_vector_type * , double);
void double_vector_free(double_vector_type *);
void double_vector_free__(void *);
void double_vector_free_data(double_vector_type *);
void double_vector_reset(double_vector_type *);
void double_vector_reset__(void * __vector);
int double_vector_size(const double_vector_type * );
double double_vector_pop(double_vector_type * vector);
double double_vector_get_first(const double_vector_type * vector);
double double_vector_get_last(const double_vector_type * );
double * double_vector_get_ptr(const double_vector_type * );
double * double_vector_alloc_data_copy( const double_vector_type * vector );
const double * double_vector_get_const_ptr(const double_vector_type * );
void double_vector_set_many(double_vector_type * , int , const double * , int );
void double_vector_set_all(double_vector_type * vector , double value);
void double_vector_append_many(double_vector_type * vector , const double * data , int length);
void double_vector_shrink(double_vector_type * );
double double_vector_sum(const double_vector_type * );
double double_vector_get_default(const double_vector_type * );
void double_vector_set_default(double_vector_type * vector, double default_value);
void double_vector_append_default(double_vector_type * vector , double default_value);
void double_vector_iset_default(double_vector_type * vector , int index , double default_value);
bool double_vector_is_sorted( const double_vector_type * vector , bool reverse);
int double_vector_index(const double_vector_type * vector , double value);
int double_vector_index_sorted(const double_vector_type * vector , double value);
void double_vector_sort(double_vector_type * vector);
void double_vector_rsort(double_vector_type * vector);
void double_vector_permute(double_vector_type * vector , const int * perm);
int * double_vector_alloc_sort_perm(const double_vector_type * vector);
int * double_vector_alloc_rsort_perm(const double_vector_type * vector);
void double_vector_fprintf(const double_vector_type * vector , FILE * stream , const char * name , const char * fmt);
void double_vector_fwrite(const double_vector_type * vector , FILE * stream);
void double_vector_buffer_fread(double_vector_type * vector , buffer_type * buffer);
double_vector_type * double_vector_fread_alloc( FILE * stream );
double_vector_type * double_vector_buffer_fread_alloc( buffer_type * buffer );
void double_vector_buffer_fwrite(const double_vector_type * vector , buffer_type * buffer);
void double_vector_fread( double_vector_type * vector , FILE * stream );
void double_vector_fwrite_data( const double_vector_type * vector , FILE * stream );
void double_vector_fread_data( double_vector_type * vector , int size, FILE * stream);
bool double_vector_equal(const double_vector_type * vector1 , const double_vector_type * vector2);
void double_vector_apply(double_vector_type * vector , double_ftype *func);
int double_vector_count_equal( const double_vector_type * vector , double cmp_value);
int double_vector_element_size( const double_vector_type * vector );
UTIL_SAFE_CAST_HEADER( double_vector );
#ifdef __cplusplus
}
#endif
#endif
//

View File

@ -1,48 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_box.h' 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.
*/
#ifndef __ECL_BOX_H__
#define __ECL_BOX_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <ecl_grid.h>
typedef struct ecl_box_struct ecl_box_type;
void ecl_box_set_size (ecl_box_type * , int , int , int , int , int , int );
ecl_box_type * ecl_box_alloc(const ecl_grid_type * ecl_grid , int i1,int i2 , int j1 , int j2 , int k1, int k2);
void ecl_box_free (ecl_box_type * );
void ecl_box_set_values(const ecl_box_type * , char * , const char * , int );
int ecl_box_get_total_size(const ecl_box_type * );
int ecl_box_get_active_size( const ecl_box_type * ecl_box );
const int * ecl_box_get_active_list( const ecl_box_type * ecl_box );
int ecl_box_get_global_size( const ecl_box_type * ecl_box );
const int * ecl_box_get_global_list( const ecl_box_type * ecl_box );
bool ecl_box_contains(const ecl_box_type * box , int i , int j , int k);
UTIL_IS_INSTANCE_HEADER( ecl_box );
UTIL_SAFE_CAST_HEADER( ecl_box );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,114 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_file.h' 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.
*/
#ifndef __ECL_FILE_H__
#define __ECL_FILE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <time.h>
#include <ecl_kw.h>
#include <ecl_file_kw.h>
#include <fortio.h>
#include <ecl_util.h>
typedef struct ecl_file_struct ecl_file_type;
void ecl_file_load_all( ecl_file_type * ecl_file );
void ecl_file_push_block( ecl_file_type * ecl_file );
void ecl_file_pop_block( ecl_file_type * ecl_file );
ecl_file_type * ecl_file_open( const char * filename );
ecl_file_type * ecl_file_open_writable( const char * filename );
void ecl_file_close( ecl_file_type * ecl_file );
void ecl_file_fortio_detach( ecl_file_type * ecl_file );
void ecl_file_free__(void * arg);
ecl_kw_type * ecl_file_icopy_named_kw( const ecl_file_type * ecl_file , const char * kw, int ith);
ecl_kw_type * ecl_file_icopy_kw( const ecl_file_type * ecl_file , int index);
bool ecl_file_has_kw( const ecl_file_type * ecl_file , const char * kw);
int ecl_file_get_num_named_kw(const ecl_file_type * ecl_file , const char * kw);
int ecl_file_get_size( const ecl_file_type * ecl_file );
int ecl_file_get_num_distinct_kw(const ecl_file_type * ecl_file);
const char * ecl_file_iget_distinct_kw(const ecl_file_type * ecl_file , int index);
const char * ecl_file_get_src_file( const ecl_file_type * ecl_file );
int ecl_file_iget_occurence( const ecl_file_type * ecl_file , int index);
ecl_version_enum ecl_file_get_ecl_version( const ecl_file_type * file );
void ecl_file_fwrite_fortio(const ecl_file_type * ec_file , fortio_type * fortio , int offset);
void ecl_file_fwrite(const ecl_file_type * ecl_file , const char * , bool fmt_file );
void ecl_file_replace_kw( ecl_file_type * ecl_file , ecl_kw_type * old_kw , ecl_kw_type * new_kw , bool insert_copy);
int ecl_file_get_phases( const ecl_file_type * init_file );
void ecl_file_fprintf_kw_list( const ecl_file_type * ecl_file , FILE * stream );
ecl_file_kw_type * ecl_file_iget_file_kw( const ecl_file_type * file , int global_index);
ecl_file_kw_type * ecl_file_iget_named_file_kw( const ecl_file_type * file , const char * kw, int ith);
ecl_kw_type * ecl_file_iget_kw( const ecl_file_type * file , int global_index);
ecl_type_enum ecl_file_iget_type( const ecl_file_type * file , int global_index);
int ecl_file_iget_size( const ecl_file_type * file , int global_index);
const char * ecl_file_iget_header( const ecl_file_type * file , int global_index);
ecl_kw_type * ecl_file_iget_named_kw( const ecl_file_type * file , const char * kw, int ith);
ecl_type_enum ecl_file_iget_named_type( const ecl_file_type * file , const char * kw , int ith);
int ecl_file_iget_named_size( const ecl_file_type * file , const char * kw , int ith);
bool ecl_file_subselect_block( ecl_file_type * ecl_file , const char * kw , int occurence);
bool ecl_file_select_block( ecl_file_type * ecl_file , const char * kw , int occurence);
void ecl_file_select_global( ecl_file_type * ecl_file );
bool ecl_file_writable( const ecl_file_type * ecl_file );
void ecl_file_save_kw( const ecl_file_type * ecl_file , const ecl_kw_type * ecl_kw);
bool ecl_file_has_kw_ptr( const ecl_file_type * ecl_file , const ecl_kw_type * ecl_kw);
/*****************************************************************/
/* R E S T A R T F I L E S */
time_t ecl_file_iget_restart_sim_date( const ecl_file_type * restart_file , int occurence );
int ecl_file_get_restart_index( const ecl_file_type * restart_file , time_t sim_time);
bool ecl_file_has_report_step( const ecl_file_type * ecl_file , int report_step);
bool ecl_file_has_sim_time( const ecl_file_type * ecl_file , time_t sim_time);
bool ecl_file_select_rstblock_sim_time( ecl_file_type * ecl_file , time_t sim_time);
bool ecl_file_select_rstblock_report_step( ecl_file_type * ecl_file , int report_step);
bool ecl_file_iselect_rstblock( ecl_file_type * ecl_file , int seqnum_index );
ecl_file_type * ecl_file_open_rstblock_report_step( const char * filename , int report_step );
ecl_file_type * ecl_file_open_rstblock_sim_time( const char * filename , time_t sim_time);
ecl_file_type * ecl_file_iopen_rstblock( const char * filename , int seqnum_index);
ecl_file_type * ecl_file_open_rstblock_report_step_writable( const char * filename , int report_step );
ecl_file_type * ecl_file_open_rstblock_sim_time_writable( const char * filename , time_t sim_time);
ecl_file_type * ecl_file_iopen_rstblock_writable( const char * filename , int seqnum_index);
/*****************************************************************/
/* SUMMARY FILES */
bool ecl_file_select_smryblock( ecl_file_type * ecl_file , int ministep_nr );
ecl_file_type * ecl_file_open_smryblock( const char * filename , int ministep_nr );
UTIL_IS_INSTANCE_HEADER( ecl_file );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,55 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_file_kw.h' 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.
*/
#ifndef __ECL_FILE_KW_H__
#define __ECL_FILE_KW_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <ecl_kw.h>
#include <fortio.h>
typedef struct ecl_file_kw_struct ecl_file_kw_type;
typedef struct inv_map_struct inv_map_type;
inv_map_type * inv_map_alloc();
ecl_file_kw_type * inv_map_get_file_kw( inv_map_type * inv_map , const ecl_kw_type * ecl_kw );
void inv_map_free( inv_map_type * map );
ecl_file_kw_type * ecl_file_kw_alloc( const ecl_kw_type * ecl_kw , long offset);
void ecl_file_kw_free( ecl_file_kw_type * file_kw );
void ecl_file_kw_free__( void * arg );
ecl_kw_type * ecl_file_kw_get_kw( ecl_file_kw_type * file_kw , fortio_type * fortio, inv_map_type * inv_map);
ecl_file_kw_type * ecl_file_kw_alloc_copy( const ecl_file_kw_type * src );
const char * ecl_file_kw_get_header( const ecl_file_kw_type * file_kw );
int ecl_file_kw_get_size( const ecl_file_kw_type * file_kw );
ecl_type_enum ecl_file_kw_get_type( const ecl_file_kw_type * file_kw);
bool ecl_file_kw_ptr_eq( const ecl_file_kw_type * file_kw , const ecl_kw_type * ecl_kw);
void ecl_file_kw_replace_kw( ecl_file_kw_type * file_kw , fortio_type * target , ecl_kw_type * new_kw );
void ecl_file_kw_fskip_data( const ecl_file_kw_type * file_kw , fortio_type * fortio);
void ecl_file_kw_inplace_fwrite( ecl_file_kw_type * file_kw , fortio_type * fortio);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,46 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_grav.h' 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.
*/
#ifndef __ECL_GRAV_H__
#define __ECL_GRAV_H__
#ifdef __plusplus
extern "C" {
#endif
#include <ecl_file.h>
#include <ecl_grid.h>
#include <ecl_region.h>
typedef struct ecl_grav_struct ecl_grav_type;
typedef struct ecl_grav_survey_struct ecl_grav_survey_type;
void ecl_grav_free( ecl_grav_type * ecl_grav_config );
ecl_grav_type * ecl_grav_alloc( const ecl_grid_type * ecl_grid, const ecl_file_type * init_file );
ecl_grav_survey_type * ecl_grav_add_survey_FIP( ecl_grav_type * grav , const char * name , const ecl_file_type * restart_file );
ecl_grav_survey_type * ecl_grav_add_survey_PORMOD( ecl_grav_type * grav , const char * name , const ecl_file_type * restart_file );
ecl_grav_survey_type * ecl_grav_add_survey_RPORV( ecl_grav_type * grav , const char * name , const ecl_file_type * restart_file );
double ecl_grav_eval( const ecl_grav_type * grav , const char * base, const char * monitor , ecl_region_type * region , double utm_x, double utm_y , double depth, int phase_mask);
void ecl_grav_new_std_density( ecl_grav_type * grav , ecl_phase_enum phase , double default_density);
void ecl_grav_add_std_density( ecl_grav_type * grav , ecl_phase_enum phase , int pvtnum , double density);
#ifdef __plusplus
}
#endif
#endif

View File

@ -1,47 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_grav.h' 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.
*/
#ifndef __ECL_GRAV_CALC_H__
#define __ECL_GRAV_CALC_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <ecl_kw.h>
#include <ecl_grid.h>
#include <ecl_file.h>
double ecl_grav_phase_deltag( double utm_x ,
double utm_y ,
double tvd,
const ecl_grid_type * grid,
const ecl_file_type * init_file ,
const ecl_kw_type * sat_kw1,
const ecl_kw_type * rho_kw1,
const ecl_kw_type * porv_kw1,
const ecl_kw_type * sat_kw2,
const ecl_kw_type * rho_kw2,
const ecl_kw_type * porv_kw2);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,38 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_grav_common.h' 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.
*/
#ifndef __ECL_GRAV_COMMON_H__
#define __ECL_GRAV_COMMON_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <ecl_grid_cache.h>
#include <ecl_file.h>
bool * ecl_grav_common_alloc_aquifer_cell( const ecl_grid_cache_type * grid_cache , const ecl_file_type * init_file);
double ecl_grav_common_eval_biot_savart( const ecl_grid_cache_type * grid_cache , ecl_region_type * region , const bool * aquifer , const double * weight , double utm_x , double utm_y , double depth);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,46 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_grid_cache.h' 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.
*/
#ifndef __ECL_GRID_CACHE_H__
#define __ECL_GRID_CACHE_H__
#include <ecl_grid.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ecl_grid_cache_struct ecl_grid_cache_type;
ecl_grid_cache_type * ecl_grid_cache_alloc( const ecl_grid_type * grid );
int ecl_grid_cache_get_size( const ecl_grid_cache_type * grid_cache );
int ecl_grid_cache_iget_global_index( const ecl_grid_cache_type * grid_cache , int active_index);
const int * ecl_grid_cache_get_global_index( const ecl_grid_cache_type * grid_cache );
const double * ecl_grid_cache_get_xpos( const ecl_grid_cache_type * grid_cache );
const double * ecl_grid_cache_get_ypos( const ecl_grid_cache_type * grid_cache );
const double * ecl_grid_cache_get_zpos( const ecl_grid_cache_type * grid_cache );
void ecl_grid_cache_free( ecl_grid_cache_type * grid_cache );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,77 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_INTEHEAD.h' 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.
*/
#ifndef __ECL_INTEHEAD_H__
#define __ECL_INTEHEAD_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#include <ecl_kw.h>
#define INTEHEAD_KW "INTEHEAD" /* Long array with lots of data. */
typedef struct {
int day;
int year;
int month;
time_t sim_time;
int version; // 100, 300, 500 (Eclipse300-Thermal)
int phase_sum; // Oil = 1 Gas = 2 Water = 4
int nx;
int ny;
int nz;
int nactive;
/*-----------------------------------------------------------------*/
/* All fields below the line are taken literally (apart from
lowercasing) from the section about restart files in the
ECLIPSE File Formats Reference Manual. The elements typically
serve as dimensions in the ?WEL, ?SEG and ?CON arrays.
*/
// Pure well properties
int nwells; // Number of wells
int niwelz; // Number of elements pr well in IWEL array
int nzwelz; // Number of 8 character words pr well in ZWEL array
// Connection properties
int niconz; // Number of elements per completion in ICON array
int ncwmax; // Maximum number of completions per well
// Segment properties
int nisegz; // Number of entries pr segment in the ISEG array
int nsegmx; // The maximum number of segments pr well
int nswlmx; // The maximum number of segmented wells
int nlbrmx; // The maximum number of lateral branches pr well
int nilbrz; // The number of entries pr segment in ILBR array
} ecl_intehead_type;
void ecl_intehead_free( ecl_intehead_type * intehead );
ecl_intehead_type * ecl_intehead_alloc( const ecl_kw_type * intehead_kw );
time_t ecl_intehead_date( const ecl_kw_type * intehead_kw );
void ecl_intehead_fprintf( const ecl_intehead_type * header , FILE * stream);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,225 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_kw.h' 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.
*/
#ifndef __ECL_KW_H__
#define __ECL_KW_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <buffer.h>
#include <fortio.h>
#include <ecl_util.h>
UTIL_IS_INSTANCE_HEADER(ecl_kw);
typedef struct ecl_kw_struct ecl_kw_type;
size_t ecl_kw_fortio_size( const ecl_kw_type * ecl_kw );
void * ecl_kw_get_ptr(const ecl_kw_type *ecl_kw);
void ecl_kw_set_data_ptr(ecl_kw_type * ecl_kw , void * data);
void ecl_kw_fwrite_data(const ecl_kw_type *_ecl_kw , fortio_type *fortio);
void ecl_kw_fread_realloc_data(ecl_kw_type *ecl_kw, fortio_type *fortio);
ecl_type_enum ecl_kw_get_type(const ecl_kw_type *);
const char * ecl_kw_get_header8(const ecl_kw_type *);
const char * ecl_kw_get_header(const ecl_kw_type * ecl_kw );
ecl_kw_type * ecl_kw_alloc_empty();
bool ecl_kw_fread_header(ecl_kw_type *, fortio_type *);
void ecl_kw_set_header_name(ecl_kw_type * , const char * );
void ecl_kw_set_header(ecl_kw_type * , const char * , int , const char *);
void ecl_kw_set_header_alloc(ecl_kw_type * , const char * , int , const char *);
bool ecl_kw_fseek_kw(const char * , bool , bool , fortio_type *);
bool ecl_kw_fseek_last_kw(const char * , bool , fortio_type *);
void ecl_kw_inplace_update_file(const ecl_kw_type * , const char * , int ) ;
void ecl_kw_fskip(fortio_type *);
void ecl_kw_alloc_data(ecl_kw_type *);
void ecl_kw_alloc_double_data(ecl_kw_type * ecl_kw , double * values);
void ecl_kw_alloc_float_data(ecl_kw_type * ecl_kw , float * values);
bool ecl_kw_fread_realloc(ecl_kw_type *, fortio_type *);
void ecl_kw_fread(ecl_kw_type * , fortio_type * );
ecl_kw_type * ecl_kw_fread_alloc(fortio_type *);
void ecl_kw_free_data(ecl_kw_type *);
void ecl_kw_free(ecl_kw_type *);
void ecl_kw_free__(void *);
ecl_kw_type * ecl_kw_alloc_copy (const ecl_kw_type *);
const void * ecl_kw_copyc__(const void *);
ecl_kw_type * ecl_kw_alloc_slice_copy( const ecl_kw_type * src, int index1, int index2, int stride);
//void * ecl_kw_get_data_ref(const ecl_kw_type *);
void * ecl_kw_alloc_data_copy(const ecl_kw_type * );
void ecl_kw_memcpy(ecl_kw_type *, const ecl_kw_type *);
void ecl_kw_get_memcpy_data(const ecl_kw_type *, void *);
void ecl_kw_get_memcpy_float_data(const ecl_kw_type *ecl_kw , float *target);
void ecl_kw_get_memcpy_double_data(const ecl_kw_type *ecl_kw , double *target);
void ecl_kw_get_memcpy_int_data(const ecl_kw_type *ecl_kw , int *target);
void ecl_kw_set_memcpy_data(ecl_kw_type * , const void *);
void ecl_kw_fwrite(const ecl_kw_type *, fortio_type *);
void ecl_kw_iget(const ecl_kw_type *, int , void *);
void ecl_kw_iset(ecl_kw_type *ecl_kw , int i , const void *iptr);
void ecl_kw_iset_char_ptr( ecl_kw_type * ecl_kw , int index, const char * s);
void ecl_kw_iset_string8(ecl_kw_type * ecl_kw , int index , const char *s8);
const char * ecl_kw_iget_char_ptr( const ecl_kw_type * ecl_kw , int i);
void * ecl_kw_iget_ptr(const ecl_kw_type *, int);
int ecl_kw_get_size(const ecl_kw_type *);
bool ecl_kw_ichar_eq(const ecl_kw_type *, int , const char *);
ecl_kw_type * ecl_kw_alloc( const char * header , int size , ecl_type_enum ecl_type );
ecl_kw_type * ecl_kw_alloc_new(const char * , int , ecl_type_enum , const void * );
ecl_kw_type * ecl_kw_alloc_new_shared(const char * , int , ecl_type_enum , void * );
void ecl_kw_fwrite_param(const char * , bool , const char * , ecl_type_enum , int , void * );
void ecl_kw_fwrite_param_fortio(fortio_type *, const char * , ecl_type_enum , int , void * );
void ecl_kw_summarize(const ecl_kw_type * ecl_kw);
void ecl_kw_fread_double_param(const char * , bool , double *);
float ecl_kw_iget_as_float(const ecl_kw_type * ecl_kw , int i);
double ecl_kw_iget_as_double(const ecl_kw_type * ecl_kw , int i);
void ecl_kw_get_data_as_double(const ecl_kw_type *, double *);
void ecl_kw_get_data_as_float(const ecl_kw_type * ecl_kw , float * float_data);
bool ecl_kw_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2);
bool ecl_kw_block_equal( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_kw2 , int cmp_elements);
bool ecl_kw_data_equal( const ecl_kw_type * ecl_kw , const void * data);
void ecl_kw_fskip_data__( ecl_type_enum ecl_type , int size , fortio_type * fortio);
void ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio);
void ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio);
void ecl_kw_fskip_header( fortio_type * fortio);
bool ecl_kw_is_grdecl_file(FILE * );
bool ecl_kw_is_kw_file(FILE * , bool );
double ecl_kw_element_sum_float( const ecl_kw_type * ecl_kw );
void ecl_kw_inplace_inv(ecl_kw_type * my_kw);
void ecl_kw_element_sum(const ecl_kw_type * , void * );
void ecl_kw_max_min(const ecl_kw_type * , void * , void *);
void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw);
ecl_kw_type * ecl_kw_buffer_alloc(buffer_type * buffer);
void ecl_kw_buffer_store(const ecl_kw_type * ecl_kw , buffer_type * buffer);
void ecl_kw_fprintf_data( const ecl_kw_type * ecl_kw , const char * fmt , FILE * stream);
void ecl_kw_memcpy_data( ecl_kw_type * target , const ecl_kw_type * src);
bool ecl_kw_assert_numeric( const ecl_kw_type * kw );
bool ecl_kw_assert_binary( const ecl_kw_type * kw1, const ecl_kw_type * kw2);
void ecl_kw_scalar_set_bool( ecl_kw_type * ecl_kw , bool bool_value);
void ecl_kw_scalar_set__(ecl_kw_type * ecl_kw , const void * value);
void ecl_kw_scalar_set_float_or_double( ecl_kw_type * ecl_kw , double value );
#define ECL_KW_SCALAR_SET_TYPED_HEADER( ctype ) void ecl_kw_scalar_set_ ## ctype( ecl_kw_type * ecl_kw , ctype value);
ECL_KW_SCALAR_SET_TYPED_HEADER( int )
ECL_KW_SCALAR_SET_TYPED_HEADER( float )
ECL_KW_SCALAR_SET_TYPED_HEADER( double )
#undef ECL_KW_SCALAR_SET_TYPED_HEADER
ecl_kw_type * ecl_kw_alloc_scatter_copy( const ecl_kw_type * src_kw , int target_size , const int * mapping, void * def_value);
void ecl_kw_inplace_add( ecl_kw_type * target_kw , const ecl_kw_type * add_kw);
void ecl_kw_inplace_sub( ecl_kw_type * target_kw , const ecl_kw_type * sub_kw);
void ecl_kw_inplace_div( ecl_kw_type * target_kw , const ecl_kw_type * div_kw);
void ecl_kw_inplace_mul( ecl_kw_type * target_kw , const ecl_kw_type * mul_kw);
void ecl_kw_inplace_add_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * add_kw);
void ecl_kw_inplace_sub_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * sub_kw);
void ecl_kw_inplace_mul_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * mul_kw);
void ecl_kw_inplace_div_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * div_kw);
void ecl_kw_copy_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * src_kw);
bool ecl_kw_assert_binary_numeric( const ecl_kw_type * kw1, const ecl_kw_type * kw2);
#define ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( ctype ) bool ecl_kw_assert_binary_ ## ctype( const ecl_kw_type * kw1 , const ecl_kw_type * kw2)
ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( int );
ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float );
ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double );
#undef ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER
#define ECL_KW_SCALE_TYPED_HEADER( ctype ) void ecl_kw_scale_ ## ctype (ecl_kw_type * ecl_kw , ctype scale_factor)
ECL_KW_SCALE_TYPED_HEADER( int );
ECL_KW_SCALE_TYPED_HEADER( float );
ECL_KW_SCALE_TYPED_HEADER( double );
#undef ECL_KW_SCALE_TYPED_HEADER
void ecl_kw_scale_float_or_double( ecl_kw_type * ecl_kw , double scale_factor );
#define ECL_KW_SHIFT_TYPED_HEADER( ctype ) void ecl_kw_shift_ ## ctype (ecl_kw_type * ecl_kw , ctype shift_factor)
ECL_KW_SHIFT_TYPED_HEADER( int );
ECL_KW_SHIFT_TYPED_HEADER( float );
ECL_KW_SHIFT_TYPED_HEADER( double );
#undef ECL_KW_SHIFT_TYPED_HEADER
void ecl_kw_shift_float_or_double( ecl_kw_type * ecl_kw , double shift_value );
#define ECL_KW_IGET_TYPED_HEADER(type) type ecl_kw_iget_ ## type(const ecl_kw_type * , int)
ECL_KW_IGET_TYPED_HEADER(double);
ECL_KW_IGET_TYPED_HEADER(float);
ECL_KW_IGET_TYPED_HEADER(int);
#undef ECL_KW_IGET_TYPED_HEADER
bool ecl_kw_iget_bool( const ecl_kw_type * ecl_kw , int i );
#define ECL_KW_ISET_TYPED_HEADER(type) void ecl_kw_iset_ ## type(ecl_kw_type * , int , type )
ECL_KW_ISET_TYPED_HEADER(double);
ECL_KW_ISET_TYPED_HEADER(float);
ECL_KW_ISET_TYPED_HEADER(int);
#undef ECL_KW_ISET_TYPED_HEADER
void ecl_kw_iset_bool( ecl_kw_type * ecl_kw , int i , bool bool_value);
#define ECL_KW_GET_TYPED_PTR_HEADER(type) type * ecl_kw_get_ ## type ## _ptr(const ecl_kw_type *)
ECL_KW_GET_TYPED_PTR_HEADER(double);
ECL_KW_GET_TYPED_PTR_HEADER(float);
ECL_KW_GET_TYPED_PTR_HEADER(int);
ECL_KW_GET_TYPED_PTR_HEADER(bool);
#undef ECL_KW_GET_TYPED_PTR_HEADER
#define ECL_KW_SET_INDEXED_HEADER(ctype ) void ecl_kw_set_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype value)
ECL_KW_SET_INDEXED_HEADER( double );
ECL_KW_SET_INDEXED_HEADER( float );
ECL_KW_SET_INDEXED_HEADER( int );
#undef ECL_KW_SET_INDEXED_HEADER
#define ECL_KW_SHIFT_INDEXED_HEADER(ctype) void ecl_kw_shift_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype shift)
ECL_KW_SHIFT_INDEXED_HEADER( int );
ECL_KW_SHIFT_INDEXED_HEADER( float );
ECL_KW_SHIFT_INDEXED_HEADER( double );
#undef ECL_KW_SHIFT_INDEXED_HEADER
#define ECL_KW_SCALE_INDEXED_HEADER(ctype) void ecl_kw_scale_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype scale)
ECL_KW_SCALE_INDEXED_HEADER( int );
ECL_KW_SCALE_INDEXED_HEADER( float );
ECL_KW_SCALE_INDEXED_HEADER( double );
#undef ECL_KW_SCALE_INDEXED_HEADER
#define ECL_KW_MAX_MIN_HEADER( ctype ) void ecl_kw_max_min_ ## ctype( const ecl_kw_type * ecl_kw , ctype * _max , ctype * _min)
ECL_KW_MAX_MIN_HEADER( int );
ECL_KW_MAX_MIN_HEADER( float );
ECL_KW_MAX_MIN_HEADER( double );
#undef ECL_KW_MAX_MIN_HEADER
#include <ecl_kw_grdecl.h>
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,318 +0,0 @@
#ifndef __ECL_KW_MAGIC_H__
#define __ECL_KW_MAGIC_H__
#ifdef __cplusplus
extern "C" {
#endif
/*
This header file contains names and indices of ECLIPSE keywords
which have special significance in various files. Observe that many
of the keywords like e.g. INTEHEAD occur in many different file
types, with partly overlapping layout and values.
*/
/*****************************************************************/
/* INIT files: */
/*****************************************************************/
#define PORO_KW "PORO"
#define PORV_KW "PORV"
#define AQUIFER_KW "AQUIFERN"
#define INTEHEAD_KW "INTEHEAD"
#define LOGIHEAD_KW "LOGIHEAD"
#define DOUBHEAD_KW "DOUBHEAD"
#define RPORV_KW "RPORV"
#define PORV_KW "PORV"
#define PORMOD_KW "PORV_MOD"
#define PVTNUM_KW "PVTNUM"
/*
Observe that many of the elements in the INTEHEAD keyword is shared
between the restart and init files. The ones listed below here are
in both the INIT and the restart files. In addition the restart
files have many well related items which are only in the restart
files.
*/
#define INTEHEAD_UNIT_INDEX 2
#define INTEHEAD_NX_INDEX 8
#define INTEHEAD_NY_INDEX 9
#define INTEHEAD_NZ_INDEX 10
#define INTEHEAD_NACTIVE_INDEX 11
#define INTEHEAD_PHASE_INDEX 14
#define INTEHEAD_DAY_INDEX 64
#define INTEHEAD_MONTH_INDEX 65
#define INTEHEAD_YEAR_INDEX 66
#define INTEHEAD_IPROG_INDEX 94
#define INTEHEAD_METRIC_VALUE 1
#define INTEHEAD_ECLIPSE100_VALUE 100
#define INTEHEAD_ECLIPSE300_VALUE 300
#define INTEHEAD_ECLIPSE300THERMAL_VALUE 500
#define INTEHEAD_INIT_SIZE 95
#define INTEHEAD_RESTART_SIZE 180
#define LOGIHEAD_ECLIPSE300_RADIAL_INDEX 3
#define LOGIHEAD_ECLIPSE100_RADIAL_INDEX 4
#define LOGIHEAD_DUALP_INDEX 14
#define LOGIHEAD_INIT_SIZE 80
#define LOGIHEAD_RESTART_SIZE 15
#define LOGIHEAD_RS_INDEX 0
#define LOGIHEAD_RV_INDEX 1
#define LOGIHEAD_DIR_RELPERM_INDEX 2
/*-----------------------------------------------------------------*/
#define LOGIHEAD_REV_RELPERM100_INDEX 3 /* The indices for reversible relperm and */
#define LOGIHEAD_RADIAL100_INDEX 4 /* use of radial grids is interchanged between */
#define LOGIHEAD_REV_RELPERM300_INDEX 4 /* ECLIPSE100 and ECLIPSE300. */
#define LOGIHEAD_RADIAL300_INDEX 3
/*-----------------------------------------------------------------*/
#define LOGIHEAD_HYSTERISIS_INDEX 6
#define LOGIHEAD_DUALP_INDEX 14
#define LOGIHEAD_ENDPOINT_SCALING_INDEX 16
#define LOGIHEAD_DIR_ENDPOINT_SCALING_INDEX 17
#define LOGIHEAD_REV_ENDPOINT_SCALING_INDEX 18
#define LOGIHEAD_ALT_ENDPOINT_SCALING_INDEX 19
#define LOGIHEAD_MISC_DISPLACEMENT_INDEX 35
#define LOGIHEAD_SCALE_WATER_PC_AT_MAX_SAT_INDEX 55
#define LOGIHEAD_SCALE_GAS_PC_AT_MAX_SAT_INDEX 56
#define DOUBHEAD_INIT_SIZE 1
#define DOUBHEAD_RESTART_SIZE 1
/*****************************************************************/
/* RESTART files: */
/*****************************************************************/
#define SEQNUM_KW "SEQNUM" /* Contains the report step as the only data; not
present in non-unified files, where the report
step must be inferred from the filename. */
#define STARTSOL_KW "STARTSOL"
#define ENDSOL_KW "ENDSOL"
#define IWEL_KW "IWEL"
#define ZWEL_KW "ZWEL"
#define ICON_KW "ICON"
#define ISEG_KW "ISEG"
#define ECLIPSE100_OIL_DEN_KW "OIL_DEN"
#define ECLIPSE100_GAS_DEN_KW "GAS_DEN"
#define ECLIPSE100_WATER_DEN_KW "WAT_DEN"
#define ECLIPSE300_OIL_DEN_KW "DENO"
#define ECLIPSE300_GAS_DEN_KW "DENG"
#define ECLIPSE300_WATER_DEN_KW "DENW"
#define FIPGAS_KW "FIPGAS"
#define FIPWAT_KW "FIPWAT"
#define FIPOIL_KW "FIPOIL"
#define RFIPGAS_KW "RFIPGAS"
#define RFIPWAT_KW "RFIPWAT"
#define RFIPOIL_KW "RFIPOIL"
#define INTEHEAD_NWELLS_INDEX 16 // Number of wells
#define INTEHEAD_NIWELZ_INDEX 24 // Number of elements pr. well in the IWEL array.
#define INTEHEAD_NZWELZ_INDEX 27 // Number of 8 character words pr. well
#define INTEHEAD_NCWMAX_INDEX 17 // Maximum number of completions per well
#define INTEHEAD_NWGMAX_INDEX 19 // Maximum number of wells in any group
#define INTEHEAD_NGMAXZ_INDEX 20 // Maximum number of groups in field
#define INTEHEAD_NICONZ_INDEX 32 // Number of elements pr completion in the ICON arra.y
#define INTEHEAD_NIGRPZ_INDEX 36 // Number of elements pr group in the IGRP array.
#define INTEHEAD_NSWLMX_INDEX 175
#define INTEHEAD_NSEGMX_INDEX 176
#define INTEHEAD_NLBRMX_INDEX 177
#define INTEHEAD_NISEGZ_INDEX 178
#define INTEHEAD_NILBRZ_INDEX 180
#define DOUBHEAD_DAYS_INDEX 0
/*****************************************************************/
/* Summary files */
/*****************************************************************/
/* Summary header file */
#define MINISTEP_KW "MINISTEP"
#define STARTDAT_KW "STARTDAT" /* Intgere keyword containing day,month,year. */
#define WGNAMES_KW "WGNAMES" /* The names of wells/groups for the summary vectors. */
#define KEYWORDS_KW "KEYWORDS" /* The variable type for the various summary vectors. */
#define UNITS_KW "UNITS" /* The units, i.e SM^3/DAY the summary vectors. */
#define DIMENS_KW "DIMENS" /* The dimensions of the grid - also used in the GRID files. */
#define NUMS_KW "NUMS" /* Extra numeric qualifiers for the summary variables, like cell number. */
#define LGRS_KW "LGRS" /* The lgr name for a vector originating from an lgr. */
#define NUMLX_KW "NUMLX" /* For block variables defined in a an lgr this is i coordinate in the lgr. */
#define NUMLY_KW "NUMLY" /* ... j coordinate in the lgr. */
#define NUMLZ_KW "NUMLZ" /* ... k coordinate in the lgr. */
/* Magic indices used to locate day,month,year from the STARTDAT keyword. */
#define STARTDAT_DAY_INDEX 0
#define STARTDAT_MONTH_INDEX 1
#define STARTDAT_YEAR_INDEX 2
#define STARTDAT_SIZE 3
/* Magic indices uset to locate the grid dimensions from the DIMENS
keyword in the SMSPEC files. Observe that these magic indices
differ from the magic indices used to look up grid dimensions from
the DIMENS keyword in GRID files. */
#define DIMENS_SMSPEC_SIZE_INDEX 0
#define DIMENS_SMSPEC_NX_INDEX 1
#define DIMENS_SMSPEC_NY_INDEX 2
#define DIMENS_SMSPEC_NZ_INDEX 3
#define DIMENS_SIZE 6 // Do not know what the two last items are?
/* Summary data files: */
#define SEQHDR_KW "SEQHDR" // Contains a single 'magic' integer - not used in libecl.
#define PARAMS_KW "PARAMS" // Contains the actual summary data for one timestep.
#define MINISTEP_KW "MINISTEP" // Scalar integer - contains the timestep number.
#define SEQHDR_SIZE 1
#define RESTART_KW "RESTART"
#define SUMMARY_RESTART_SIZE 8
/*
There are no magic indices in the summary data files, for all
interesting data the table created from the ecl_smspec file must be
consulted.
*/
/*****************************************************************/
/* RFT Files */
/*****************************************************************/
/* The files with extension .RFT can contain three quite different
types of information: RFT / PLT / SEGMENT, this is indicated by an
element of the WELLETC keyword. The keywords below are organized in
common keywords, keywords for RFTs and keywords for PLTs. The
special information for SEGMENT data is not internalized at all,
and there are also several additional keywords for the PLTs which
are not internalized. */
/* Common keywords */
#define TIME_KW "TIME" /* The days since simulation start when
an RFT is performed, also used as
block header when splitting an RFT
file into different wells and timesteps. */
#define DATE_KW "DATE" /* The date of an RFT as integers: (day,month,year). */
#define WELLETC_KW "WELLETC" /* The type of date RFT|PLT|SEGMENT and well name are
extracted from this keyword. */
#define CONIPOS_KW "CONIPOS" /* The i-index of the connections in the well. */
#define CONJPOS_KW "CONJPOS" /* The j-index ... */
#define CONKPOS_KW "CONKPOS" /* The k-index ... */
/* RFT keywords */
#define SWAT_KW "SWAT" /* The kewyord containing SWAT. */
#define SGAS_KW "SGAS" /* The kewyord containing SGAS. */
#define PRESSURE_KW "PRESSURE" /* The kewyord containing PRESSURE. */
#define DEPTH_KW "DEPTH" /* The depth of the connection. */
/* PLT keywords */
#define CONDEPTH_KW "CONDEPTH" /* The depth of the connection. */
#define CONWRAT_KW "CONWRAT" /* Water rate in a connection. */
#define CONGRAT_KW "CONGRAT" /* Gas ... */
#define CONORAT_KW "CONORAT" /* Oil ... */
#define CONPRES_KW "CONPRES" /* Pressure ... */
#define WELLETC_TYPE_INDEX 5 /* At this keyword the WELLETC keyword contains a string
containing 'R', 'P' , or 'S' for RFT, PLT or SEGMENT data
respectively.*/
#define WELLETC_NAME_INDEX 1 /* The name of well being investigated is on this index of
the WELLETC keyword. */
/* Magic indices used to get day,month,year from the DATE
keyword. */
#define DATE_DAY_INDEX 0
#define DATE_MONTH_INDEX 1
#define DATE_YEAR_INDEX 2
/*****************************************************************/
/* GRID and EGRID files. */
/*****************************************************************/
/* GRID and EGRID files have very different structure, and only a few
keywords are shared. */
/* Common keywords */
#define SPECGRID_KW "SPECGRID"
#define SPECGRID_NX_INDEX 0
#define SPECGRID_NY_INDEX 1
#define SPECGRID_NZ_INDEX 2
#define MAPAXES_KW "MAPAXES" /* Keyword used to transform from grid coordinates to
world coordinates. */
#define LGR_KW "LGR" /* Name of LGR; for GRID files it can contain two elements,
the second element will be the name of the parent. */
#define MAPUNITS_KW "MAPUNITS"
#define GRIDUNIT_KW "GRIDUNIT"
/* EGRID keywords */
#define LGR_PARENT_KW "LGRPARNT" /* The name of the parent for an LGR. */
#define COORDS_KW "COORDS" /* The (x,y) coordinates of the top and bottom of the pillars constituting the grid. */
#define ZCORN_KW "ZCORN" /* Z coordinate where pillars cross planes. */
#define ACTNUM_KW "ACTNUM" /* Integer flag of with active=0,1. */
#define HOSTNUM_KW "HOSTNUM" /* For cells in LGR - pointing back to cell nr in
parent grid. */
#define FILEHEAD_KW "FILEHEAD"
#define ENDGRID_KW "ENDGRID"
#define ENDLGR_KW "ENDLGR"
/* GRID keywords */
#define GRIDHEAD_KW "GRIDHEAD" /* Header information for GRID files. */
#define COORD_KW "COORD" /* Header information for one cell in GRID file. */
#define CORNERS_KW "CORNERS" /* Vector containing (x,y,z) x 8 elements - all corners in a cell. */
#define DIMENS_KW "DIMENS" /* The dimensions of the grid. */
#define RADIAL_KW "RADIAL"
#define GLOBAL_STRING "GLOBAL"
#define GRIDHEAD_TYPE_INDEX 0
#define GRIDHEAD_NX_INDEX 1
#define GRIDHEAD_NY_INDEX 2
#define GRIDHEAD_NZ_INDEX 3
#define GRIDHEAD_LGR_INDEX 4
#define GRIDHEAD_SIZE 100
/* Observe that these indices are one value lower than the values used
in the ecl_smspec file. */
#define DIMENS_NX_INDEX 0
#define DIMENS_NY_INDEX 1
#define DIMENS_NZ_INDEX 2
#define FILEHEAD_VERSION_INDEX 0
#define FILEHEAD_YEAR_INDEX 1
#define FILEHEAD_COMPAT_INDEX 3
#define FILEHEAD_TYPE_INDEX 4
#define FILEHEAD_DUALP_INDEX 5
#define FILEHEAD_ORGFORMAT_INDEX 6
#define GRIDHEAD_GRIDTYPE_CORNERPOINT 1 /* <----\ */
/* | Fucking hysterical! */
#define FILEHEAD_GRIDTYPE_CORNERPOINT 0 /* <----/ */
#define FILEHEAD_SINGLE_POROSITY 0
#define FILEHEAD_ORGTYPE_CORNERPOINT 1
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,191 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_region.h' 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.
*/
#ifndef __ECL_REGION_H__
#define __ECL_REGION_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <int_vector.h>
#include <geo_polygon.h>
#include <ecl_box.h>
#include <ecl_grid.h>
typedef enum {
SELECT_ALL = 0,
DESELECT_ALL = 1,
SELECT_FROM_IJK = 2,
DESELECT_FROM_IJK = 3,
SELECT_FROM_I = 4,
DSELECT_FROM_I = 5,
SELECT_FROM_J = 6,
DSELECT_FROM_J = 7,
SELECT_FROM_K = 8,
DSELECT_FROM_K = 9,
SELECT_EQUAL = 10,
DESELECT_EQUAL = 11,
SELECT_IN_INTERVAL = 12,
DESELECT_IN_INTERVAL = 13,
INVERT_SELECTION = 14
} ecl_region_select_cmd;
typedef struct ecl_region_struct ecl_region_type;
void ecl_region_unlock( ecl_region_type * region );
void ecl_region_lock( ecl_region_type * region );
void ecl_region_reset( ecl_region_type * ecl_region );
ecl_region_type * ecl_region_alloc_copy( const ecl_region_type * ecl_region );
ecl_region_type * ecl_region_alloc( const ecl_grid_type * ecl_grid , bool preselect);
void ecl_region_free( ecl_region_type * region );
void ecl_region_free__( void * __region );
const int_vector_type * ecl_region_get_active_list( ecl_region_type * region );
const int_vector_type * ecl_region_get_global_list( ecl_region_type * region );
const int_vector_type * ecl_region_get_global_active_list( ecl_region_type * region );
bool ecl_region_contains_ijk( const ecl_region_type * ecl_region , int i , int j , int k);
bool ecl_region_contains_global( const ecl_region_type * ecl_region , int global_index);
bool ecl_region_contains_active( const ecl_region_type * ecl_region , int active_index);
void ecl_region_invert_selection( ecl_region_type * region );
void ecl_region_select_all( ecl_region_type * region);
void ecl_region_deselect_all( ecl_region_type * region );
void ecl_region_select_in_interval( ecl_region_type * region , const ecl_kw_type * ecl_kw, float min_value , float max_value);
void ecl_region_deselect_in_interval( ecl_region_type * region , const ecl_kw_type * ecl_kw, float min_value , float max_value);
void ecl_region_select_equal( ecl_region_type * region , const ecl_kw_type * ecl_kw, int value);
void ecl_region_deselect_equal( ecl_region_type * region , const ecl_kw_type * ecl_kw, int value);
void ecl_region_select_inactive_cells( ecl_region_type * region );
void ecl_region_deselect_inactive_cells( ecl_region_type * region );
void ecl_region_select_active_cells( ecl_region_type * region );
void ecl_region_deselect_active_cells( ecl_region_type * region );
void ecl_region_select_from_box( ecl_region_type * region , const ecl_box_type * ecl_box );
void ecl_region_deselect_from_box( ecl_region_type * region , const ecl_box_type * ecl_box );
void ecl_region_select_from_ijkbox( ecl_region_type * region , int i1 , int i2 , int j1 , int j2 , int k1 , int k2);
void ecl_region_deselect_from_ijkbox( ecl_region_type * region , int i1 , int i2 , int j1 , int j2 , int k1 , int k2);
void ecl_region_select_i1i2( ecl_region_type * region , int i1 , int i2);
void ecl_region_deselect_i1i2( ecl_region_type * region , int i1 , int i2);
void ecl_region_select_j1j2( ecl_region_type * region , int j1 , int j2);
void ecl_region_deselect_j1j2( ecl_region_type * region , int j1 , int i2);
void ecl_region_select_k1k2( ecl_region_type * region , int k1 , int k2);
void ecl_region_deselect_k1k2( ecl_region_type * region , int k1 , int i2);
void ecl_region_select_shallow_cells( ecl_region_type * region , double depth_limit );
void ecl_region_deselect_shallow_cells( ecl_region_type * region , double depth_limit );
void ecl_region_select_deep_cells( ecl_region_type * region , double depth_limit );
void ecl_region_deselect_deep_cells( ecl_region_type * region , double depth_limit );
void ecl_region_select_thin_cells( ecl_region_type * ecl_region , double dz_limit );
void ecl_region_deselect_thin_cells( ecl_region_type * ecl_region , double dz_limit );
void ecl_region_select_thick_cells( ecl_region_type * ecl_region , double dz_limit );
void ecl_region_deselect_thick_cells( ecl_region_type * ecl_region , double dz_limit );
void ecl_region_select_small_cells( ecl_region_type * ecl_region , double volum_limit );
void ecl_region_deselect_small_cells( ecl_region_type * ecl_region , double volum_limit );
void ecl_region_select_large_cells( ecl_region_type * ecl_region , double volum_limit );
void ecl_region_deselect_large_cells( ecl_region_type * ecl_region , double volum_limit );
void ecl_region_select_global_index( ecl_region_type * ecl_region , int global_index);
void ecl_region_deselect_global_index( ecl_region_type * ecl_region , int global_index);
void ecl_region_select_active_index( ecl_region_type * ecl_region , int active_index);
void ecl_region_deselect_active_index( ecl_region_type * ecl_region , int active_index);
void ecl_region_intersection( ecl_region_type * region , const ecl_region_type * new_region );
void ecl_region_union( ecl_region_type * region , const ecl_region_type * new_region );
void ecl_region_subtract( ecl_region_type * region , const ecl_region_type * new_region);
void ecl_region_xor( ecl_region_type * region , const ecl_region_type * new_region);
void ecl_region_select_smaller( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , float limit);
void ecl_region_deselect_smaller( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , float limit);
void ecl_region_select_larger( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , float limit);
void ecl_region_deselect_larger( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , float limit);
void ecl_region_cmp_select_less( ecl_region_type * ecl_region , const ecl_kw_type * kw1 , const ecl_kw_type * kw2);
void ecl_region_cmp_deselect_less( ecl_region_type * ecl_region , const ecl_kw_type * kw1 , const ecl_kw_type * kw2);
void ecl_region_cmp_select_more( ecl_region_type * ecl_region , const ecl_kw_type * kw1 , const ecl_kw_type * kw2);
void ecl_region_cmp_deselect_more( ecl_region_type * ecl_region , const ecl_kw_type * kw1 , const ecl_kw_type * kw2);
void ecl_region_select_in_cylinder( ecl_region_type * region , double x0 , double y0, double R);
void ecl_region_deselect_in_cylinder( ecl_region_type * region , double x0 , double y0, double R);
void ecl_region_select_in_zcylinder( ecl_region_type * region , double x0 , double y0, double R , double z1 , double z2);
void ecl_region_deselect_in_zcylinder( ecl_region_type * region , double x0 , double y0, double R, double z1 , double z2);
void ecl_region_select_above_plane( ecl_region_type * region, const double n[3] , const double p[3]);
void ecl_region_select_below_plane( ecl_region_type * region, const double n[3] , const double p[3]);
void ecl_region_deselect_above_plane( ecl_region_type * region, const double n[3] , const double p[3]);
void ecl_region_deselect_below_plane( ecl_region_type * region, const double n[3] , const double p[3]);
void ecl_region_select_inside_polygon( ecl_region_type * region , const geo_polygon_type * polygon);
void ecl_region_deselect_inside_polygon( ecl_region_type * region , const geo_polygon_type * polygon);
void ecl_region_select_outside_polygon( ecl_region_type * region , const geo_polygon_type * polygon);
void ecl_region_deselect_outside_polygon( ecl_region_type * region , const geo_polygon_type * polygon);
/*****************************************************************/
/* Functions to manipulate ecl_kw instances . */
void ecl_region_set_kw_int( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , int value, bool force_active);
void ecl_region_set_kw_float( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , float value , bool force_active);
void ecl_region_set_kw_double( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , double value , bool force_active);
void ecl_region_kw_copy( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , const ecl_kw_type * src_kw , bool force_active);
int ecl_region_get_kw_size( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , bool force_active);
void ecl_region_kw_iadd( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , const ecl_kw_type * delta_kw , bool force_active);
void ecl_region_kw_idiv( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , const ecl_kw_type * div_kw , bool force_active);
void ecl_region_kw_imul( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , const ecl_kw_type * mul_kw , bool force_active);
void ecl_region_kw_isub( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , const ecl_kw_type * delta_kw , bool force_active);
/*****************************************************************/
/* set/get the name */
void ecl_region_set_name( ecl_region_type * region , const char * name );
const char * ecl_region_get_name( const ecl_region_type * region );
/*****************************************************************/
/* Stupid cpp compat/legacy/cruft functions. */
int ecl_region_get_active_size_cpp( ecl_region_type * region );
int ecl_region_get_global_size_cpp( ecl_region_type * region );
const int * ecl_region_get_active_list_cpp( ecl_region_type * region );
const int * ecl_region_get_global_list_cpp( ecl_region_type * region );
/*****************************************************************/
UTIL_IS_INSTANCE_HEADER( ecl_region );
UTIL_SAFE_CAST_HEADER( ecl_region );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,60 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_rft_file.h' 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.
*/
#ifndef __ECL_RFT_FILE_H__
#define __ECL_RFT_FILE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stringlist.h>
#include <ecl_rft_node.h>
typedef struct ecl_rft_file_struct ecl_rft_file_type;
char * ecl_rft_file_alloc_case_filename(const char * case_input );
const char * ecl_rft_file_get_filename( const ecl_rft_file_type * rft_file );
ecl_rft_file_type * ecl_rft_file_alloc_case(const char * case_input );
bool ecl_rft_file_case_has_rft(const char * case_input );
bool ecl_rft_file_case_has_rft( const char * case_input );
ecl_rft_file_type * ecl_rft_file_alloc(const char * );
void ecl_rft_file_free(ecl_rft_file_type * );
void ecl_rft_file_block(const ecl_rft_file_type * , double , const char * , int , const double * , int * , int * , int *);
void ecl_rft_file_fprintf_rft_obs(const ecl_rft_file_type * , double , const char * , const char *, const char * , double);
ecl_rft_node_type * ecl_rft_file_get_node(const ecl_rft_file_type * , const char * );
void ecl_rft_file_summarize(const ecl_rft_file_type * , bool );
void ecl_rft_file_xml_summary( const ecl_rft_file_type * rft_file );
const ecl_rft_node_type * ecl_rft_file_get_well_time_rft( const ecl_rft_file_type * rft_file , const char * well , time_t recording_time);
int ecl_rft_file_get_size__( const ecl_rft_file_type * rft_file, const char * well_pattern , time_t recording_time);
int ecl_rft_file_get_size( const ecl_rft_file_type * rft_file);
const ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file , int index);
const ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_file , const char * well, int index);
bool ecl_rft_file_has_well( const ecl_rft_file_type * rft_file , const char * well);
int ecl_rft_file_get_well_occurences( const ecl_rft_file_type * rft_file , const char * well);
stringlist_type * ecl_rft_file_alloc_well_list(const ecl_rft_file_type * rft_file );
int ecl_rft_file_get_num_wells( const ecl_rft_file_type * rft_file );
void ecl_rft_file_free__( void * arg);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,142 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_smspec.h' 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.
*/
#ifndef __ECL_SMSPEC__
#define __ECL_SMSPEC__
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#include <stdbool.h>
#include <float_vector.h>
#include <stringlist.h>
#include <smspec_node.h>
typedef struct ecl_smspec_struct ecl_smspec_type;
/**
These are the different variable types, see table 3.4 in the
ECLIPFE file format docuemntation for naming conventions.
Only the variable types marked with "X" below are supported in the
remaining implementation. To add support for a new variable type
the functions smspec_node_alloc(), ecl_smsepec_fread_header() and
ecl_smspec_install_gen_key() must be updated.
*/
const int_vector_type * ecl_smspec_get_index_map( const ecl_smspec_type * smspec );
void ecl_smspec_index_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node);
void ecl_smspec_insert_node(ecl_smspec_type * ecl_smspec, smspec_node_type * smspec_node);
void ecl_smspec_add_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node );
ecl_smspec_var_type ecl_smspec_iget_var_type( const ecl_smspec_type * smspec , int index );
bool ecl_smspec_needs_num( ecl_smspec_var_type var_type );
bool ecl_smspec_needs_wgname( ecl_smspec_var_type var_type );
const char * ecl_smspec_get_var_type_name( ecl_smspec_var_type var_type );
ecl_smspec_var_type ecl_smspec_identify_var_type(const char * var);
ecl_smspec_type * ecl_smspec_alloc_writer( const char * key_join_string , time_t sim_start , int nx , int ny , int nz);
void ecl_smspec_fwrite( const ecl_smspec_type * smspec , const char * ecl_case , bool fmt_file );
ecl_smspec_type * ecl_smspec_fread_alloc(const char *header_file, const char * key_join_string , bool include_restart);
void ecl_smspec_free( ecl_smspec_type *);
int ecl_smspec_get_sim_days_index( const ecl_smspec_type * smspec );
int ecl_smspec_get_date_day_index( const ecl_smspec_type * smspec );
int ecl_smspec_get_date_month_index( const ecl_smspec_type * smspec );
int ecl_smspec_get_date_year_index( const ecl_smspec_type * smspec );
const smspec_node_type * ecl_smspec_get_well_var_node( const ecl_smspec_type * smspec , const char * well , const char * var);
int ecl_smspec_get_well_var_params_index(const ecl_smspec_type * ecl_smspec , const char * well , const char *var);
bool ecl_smspec_has_well_var(const ecl_smspec_type * ecl_smspec , const char * well , const char *var);
const smspec_node_type * ecl_smspec_get_group_var_node( const ecl_smspec_type * smspec , const char * group , const char * var);
int ecl_smspec_get_group_var_params_index(const ecl_smspec_type * ecl_smspec , const char * group , const char *var);
bool ecl_smspec_has_group_var(const ecl_smspec_type * ecl_smspec , const char * group , const char *var);
const smspec_node_type * ecl_smspec_get_field_var_node( const ecl_smspec_type * smspec , const char * var);
int ecl_smspec_get_field_var_params_index(const ecl_smspec_type * ecl_smspec , const char *var);
bool ecl_smspec_has_field_var(const ecl_smspec_type * ecl_smspec , const char *var);
const smspec_node_type * ecl_smspec_get_region_var_node(const ecl_smspec_type * ecl_smspec , const char *region_var , int region_nr);
int ecl_smspec_get_region_var_params_index(const ecl_smspec_type * ecl_smspec , const char * region_var , int region_nr);
bool ecl_smspec_has_region_var(const ecl_smspec_type * ecl_smspec , const char * region_var , int region_nr);
const smspec_node_type * ecl_smspec_get_misc_var_node(const ecl_smspec_type * ecl_smspec , const char *var);
int ecl_smspec_get_misc_var_params_index(const ecl_smspec_type * ecl_smspec , const char *var);
bool ecl_smspec_has_misc_var(const ecl_smspec_type * ecl_smspec , const char *var);
const smspec_node_type * ecl_smspec_get_block_var_node(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr);
int ecl_smspec_get_block_var_params_index(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr);
bool ecl_smspec_has_block_var(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr);
const smspec_node_type * ecl_smspec_get_block_var_node_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k);
int ecl_smspec_get_block_var_params_index_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k);
bool ecl_smspec_has_block_var_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k);
const smspec_node_type * ecl_smspec_get_well_completion_var_node(const ecl_smspec_type * ecl_smspec , const char * well , const char *var, int cell_nr);
int ecl_smspec_get_well_completion_var_params_index(const ecl_smspec_type * ecl_smspec , const char * well , const char *var, int cell_nr);
bool ecl_smspec_has_well_completion_var(const ecl_smspec_type * ecl_smspec , const char * well , const char *var, int cell_nr);
const smspec_node_type * ecl_smspec_get_general_var_node( const ecl_smspec_type * smspec , const char * lookup_kw );
int ecl_smspec_get_general_var_params_index(const ecl_smspec_type * ecl_smspec , const char * lookup_kw);
bool ecl_smspec_has_general_var(const ecl_smspec_type * ecl_smspec , const char * lookup_kw);
const char * ecl_smspec_get_general_var_unit( const ecl_smspec_type * ecl_smspec , const char * lookup_kw);
//bool ecl_smspec_general_is_total(const ecl_smspec_type * ecl_smspec , const char * gen_key);
//bool ecl_smspec_is_rate(const ecl_smspec_type * smspec , int kw_index);
//ecl_smspec_var_type ecl_smspec_iget_var_type( const ecl_smspec_type * smspec , int index );
//const char * ecl_smspec_iget_unit( const ecl_smspec_type * smspec , int index );
//int ecl_smspec_iget_num( const ecl_smspec_type * smspec , int index );
//const char * ecl_smspec_iget_wgname( const ecl_smspec_type * smspec , int index );
//const char * ecl_smspec_iget_keyword( const ecl_smspec_type * smspec , int index );
void ecl_smspec_init_var( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num, const char * unit );
void ecl_smspec_select_matching_general_var_list( const ecl_smspec_type * smspec , const char * pattern , stringlist_type * keys);
stringlist_type * ecl_smspec_alloc_matching_general_var_list(const ecl_smspec_type * smspec , const char * pattern);
int ecl_smspec_get_time_index( const ecl_smspec_type * ecl_smspec );
time_t ecl_smspec_get_start_time(const ecl_smspec_type * );
/*****************************************************************/
bool ecl_smspec_get_formatted( const ecl_smspec_type * ecl_smspec);
const char * ecl_smspec_get_header_file( const ecl_smspec_type * ecl_smspec );
stringlist_type * ecl_smspec_alloc_well_list( const ecl_smspec_type * smspec , const char * pattern);
stringlist_type * ecl_smspec_alloc_group_list( const ecl_smspec_type * smspec , const char * pattern);
stringlist_type * ecl_smspec_alloc_well_var_list( const ecl_smspec_type * smspec );
const char * ecl_smspec_get_simulation_path(const ecl_smspec_type * ecl_smspec);
const stringlist_type * ecl_smspec_get_restart_list( const ecl_smspec_type * ecl_smspec);
const char * ecl_smspec_get_join_string( const ecl_smspec_type * smspec);
const float_vector_type * ecl_smspec_get_params_default( const ecl_smspec_type * ecl_smspec );
void ecl_smspec_update_wgname( ecl_smspec_type * smspec , smspec_node_type * node , const char * wgname );
const int * ecl_smspec_get_grid_dims( const ecl_smspec_type * smspec );
int ecl_smspec_get_params_size( const ecl_smspec_type * smspec );
const smspec_node_type * ecl_smspec_iget_node( const ecl_smspec_type * smspec , int index );
void ecl_smspec_lock( ecl_smspec_type * smspec );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,47 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_subsidence.h' 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.
*/
#ifndef __ECL_SUBSIDENCE_H__
#define __ECL_SUBSICENCE_H__
#ifdef __plusplus
extern "C" {
#endif
#include <ecl_file.h>
#include <ecl_grid.h>
#include <ecl_region.h>
typedef struct ecl_subsidence_struct ecl_subsidence_type;
typedef struct ecl_subsidence_survey_struct ecl_subsidence_survey_type;
void ecl_subsidence_free( ecl_subsidence_type * ecl_subsidence_config );
ecl_subsidence_type * ecl_subsidence_alloc( const ecl_grid_type * ecl_grid, const ecl_file_type * init_file );
ecl_subsidence_survey_type * ecl_subsidence_add_survey_PRESSURE( ecl_subsidence_type * subsidence ,
const char * name , const ecl_file_type * restart_file );
double ecl_subsidence_eval( const ecl_subsidence_type * subsidence ,
const char * base, const char * monitor ,
ecl_region_type * region ,
double utm_x, double utm_y , double depth, double compressibility, double poisson_ratio);
#ifdef __plusplus
}
#endif
#endif

View File

@ -1,87 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_sum_data.h' 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.
*/
#ifndef __ECL_SUM_DATA_H__
#define __ECL_SUM_DATA_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <time.h>
#include <time_t_vector.h>
#include <double_vector.h>
#include <stringlist.h>
#include <ecl_sum_tstep.h>
#include <smspec_node.h>
typedef struct ecl_sum_data_struct ecl_sum_data_type ;
void ecl_sum_data_fwrite_step( const ecl_sum_data_type * data , const char * ecl_case , bool fmt_case , bool unified, int report_step);
void ecl_sum_data_fwrite( const ecl_sum_data_type * data , const char * ecl_case , bool fmt_case , bool unified);
void ecl_sum_data_fread( ecl_sum_data_type * data , const stringlist_type * filelist);
void ecl_sum_data_fread_restart( ecl_sum_data_type * data , const stringlist_type * filelist);
ecl_sum_data_type * ecl_sum_data_alloc_writer( ecl_smspec_type * smspec );
ecl_sum_data_type * ecl_sum_data_alloc( ecl_smspec_type * smspec);
int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type * data , time_t sim_time);
int ecl_sum_data_get_report_step_from_days(const ecl_sum_data_type * data , double days);
bool ecl_sum_data_check_sim_time( const ecl_sum_data_type * data , time_t sim_time);
bool ecl_sum_data_check_sim_days( const ecl_sum_data_type * data , double sim_days);
int ecl_sum_data_get_num_ministep( const ecl_sum_data_type * data );
double_vector_type * ecl_sum_data_alloc_data_vector( const ecl_sum_data_type * data , int data_index , bool report_only);
void ecl_sum_data_init_data_vector( const ecl_sum_data_type * data , double_vector_type * data_vector , int data_index , bool report_only);
void ecl_sum_data_init_time_vector( const ecl_sum_data_type * data , time_t_vector_type * time_vector , bool report_only);
time_t_vector_type * ecl_sum_data_alloc_time_vector( const ecl_sum_data_type * data , bool report_only);
time_t ecl_sum_data_get_data_start( const ecl_sum_data_type * data );
time_t ecl_sum_data_get_report_time( const ecl_sum_data_type * data , int report_step);
double ecl_sum_data_get_first_day( const ecl_sum_data_type * data);
time_t ecl_sum_data_get_sim_start ( const ecl_sum_data_type * data );
time_t ecl_sum_data_get_sim_end ( const ecl_sum_data_type * data );
double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data );
void ecl_sum_data_summarize(const ecl_sum_data_type * data , FILE * stream);
double ecl_sum_data_iget( const ecl_sum_data_type * data , int internal_index , int params_index );
double ecl_sum_data_iget_sim_days( const ecl_sum_data_type * , int );
time_t ecl_sum_data_iget_sim_time( const ecl_sum_data_type * , int );
bool ecl_sum_data_has_report_step(const ecl_sum_data_type * , int );
ecl_sum_data_type * ecl_sum_data_fread_alloc( ecl_smspec_type * , const stringlist_type * filelist , bool include_restart);
void ecl_sum_data_free( ecl_sum_data_type * );
int ecl_sum_data_get_last_report_step( const ecl_sum_data_type * data );
int ecl_sum_data_get_first_report_step( const ecl_sum_data_type * data );
int ecl_sum_data_get_first_ministep( const ecl_sum_data_type * data );
int ecl_sum_data_get_last_ministep( const ecl_sum_data_type * data );
double ecl_sum_data_get_from_sim_time( const ecl_sum_data_type * data , time_t sim_time , const smspec_node_type * smspec_node);
double ecl_sum_data_get_from_sim_days( const ecl_sum_data_type * data , double sim_days , const smspec_node_type * smspec_node);
int ecl_sum_data_get_length( const ecl_sum_data_type * data );
int ecl_sum_data_iget_report_step(const ecl_sum_data_type * data , int internal_index);
int ecl_sum_data_iget_mini_step(const ecl_sum_data_type * data , int internal_index);
int ecl_sum_data_iget_report_end( const ecl_sum_data_type * data , int report_step );
int ecl_sum_data_iget_report_start( const ecl_sum_data_type * data , int report_step );
ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int report_step , double sim_days);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,184 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_util.h' 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.
*/
#ifndef __ECL_UTIL_H__
#define __ECL_UTIL_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <time.h>
#include <stringlist.h>
typedef enum { ECL_OTHER_FILE = 0 ,
ECL_RESTART_FILE = 1 ,
ECL_UNIFIED_RESTART_FILE = 2 ,
ECL_SUMMARY_FILE = 4 ,
ECL_UNIFIED_SUMMARY_FILE = 8 ,
ECL_SUMMARY_HEADER_FILE = 16 ,
ECL_GRID_FILE = 32 ,
ECL_EGRID_FILE = 64 ,
ECL_INIT_FILE = 128 ,
ECL_RFT_FILE = 256 ,
ECL_DATA_FILE = 512 } ecl_file_enum;
#define ECL_FILE_ENUM_DEFS {.value = 0 , .name="ECL_OTHER_FILE"}, \
{.value = 1 , .name="ECL_RESTART_FILE"}, \
{.value = 2 , .name="ECL_UNIFIED_RESTART_FILE"}, \
{.value = 4 , .name="ECL_SUMMARY_FILE"}, \
{.value = 8 , .name="ECL_UNIFIED_SUMMARY_FILE"}, \
{.value = 16 , .name="ECL_SUMMARY_HEADER_FILE"}, \
{.value = 32 , .name="ECL_GRID_FILE"}, \
{.value = 64 , .name="ECL_EGRID_FILE"}, \
{.value = 128 , .name="ECL_INIT_FILE"}, \
{.value = 256 , .name="ECL_RFT_FILE"}, \
{.value = 512 , .name="ECL_DATA_FILE"}
#define ECL_FILE_ENUM_SIZE 11
/*
This enum enumerates the four different ways summary and restart information
can be stored.
*/
typedef enum { ECL_INVALID_STORAGE = 0,
ECL_BINARY_UNIFIED = 1,
ECL_FORMATTED_UNIFIED = 2,
ECL_BINARY_NON_UNIFIED = 4,
ECL_FORMATTED_NON_UNIFIED = 8} ecl_storage_enum;
/*
Character data in ECLIPSE files comes as an array of fixed-length
string. Each of these strings is 8 characters long. The type name,
i.e. 'REAL', 'INTE', ... , come as 4 character strings.
*/
#define ECL_STRING_LENGTH 8
#define ECL_TYPE_LENGTH 4
/*****************************************************************/
/*
Observe that these type identidiers are (ab)used in both the rms and
ert/enkf libraries in situations where ECLIPSE is not at all involved.
*/
typedef enum {
ECL_CHAR_TYPE = 0,
ECL_FLOAT_TYPE = 1,
ECL_DOUBLE_TYPE = 2,
ECL_INT_TYPE = 3,
ECL_BOOL_TYPE = 4,
ECL_MESS_TYPE = 5
} ecl_type_enum;
#define ECL_TYPE_ENUM_DEFS {.value = 0 , .name = "ECL_CHAR_TYPE"}, \
{.value = 1 , .name = "ECL_FLOAT_TYPE"} , \
{.value = 2 , .name = "ECL_DOUBLE_TYPE"}, \
{.value = 3 , .name = "ECL_INT_TYPE"}, \
{.value = 4 , .name = "ECL_BOOL_TYPE"}, \
{.value = 5 , .name = "ECL_MESS_TYPE"}
#define ECL_TYPE_ENUM_SIZE 6
/*
The libecl library has been built and tested 99.5% with ECLIPSE100
as context, but in thye gravity code there is some very limited
functionality related to ECLIPSE100 versus ECLIPSE300 functionality.
*/
typedef enum {
ECLIPSE_UNDEFINED = 0,
ECLIPSE100 = 1,
ECLIPSE300 = 2
} ecl_version_enum;
/*
Observe that the numerical enum VALUES matches those found in item
14 in the INTEHEAD keyword in the ECLIPSE INIT files; i.e. the
distribution of numerical values 1,2,4 can NOT BE CHANGED.
The function ecl_util_get_phase_name() can be used to lookup a
string name from an enum value.
The phases in a simulation will typically be a sum of these
fundamental phases, and represented as an integer.
*/
typedef enum {
ECL_OIL_PHASE = 1,
ECL_GAS_PHASE = 2,
ECL_WATER_PHASE = 4
} ecl_phase_enum;
#define ECL_PHASE_ENUM_DEFS {.value = 1 , .name = "ECL_OIL_PHASE"}, {.value = 2 , .name = "ECL_GAS_PHASE"} , {.value = 4 , .name = "ECL_WATER_PHASE"}
#define ECL_PHASE_ENUM_SIZE 3
// For unformatted files:
#define ECL_BOOL_TRUE_INT -1 // Binary representation: 11111111 11111111 11111111 1111111
#define ECL_BOOL_FALSE_INT 0 // Binary representation: 00000000 00000000 00000000 0000000
#define ECL_COMMENT_STRING "--"
#define ECL_COMMENT_CHAR '-' // Need to consecutive to make an ECLIPSE comment
#define ECL_DATA_TERMINATION "/"
int ecl_util_get_sizeof_ctype_fortio(ecl_type_enum ecl_type);
int ecl_util_get_sizeof_ctype(ecl_type_enum );
ecl_type_enum ecl_util_get_type_from_name( const char * type_name );
const char * ecl_util_get_type_name( ecl_type_enum ecl_type );
/*****************************************************************/
bool ecl_util_unified_file(const char *filename);
const char * ecl_util_file_type_name( ecl_file_enum file_type );
char * ecl_util_alloc_base_guess(const char *);
int ecl_util_filename_report_nr(const char *);
ecl_file_enum ecl_util_get_file_type(const char * , bool * , int * );
ecl_file_enum ecl_util_inspect_extension(const char * ext , bool *_fmt_file, int * _report_nr);
char * ecl_util_alloc_filename(const char * /* path */, const char * /* base */, ecl_file_enum , bool /* fmt_file */ , int /*report_nr*/);
char * ecl_util_alloc_exfilename(const char * /* path */, const char * /* base */, ecl_file_enum , bool /* fmt_file */ , int /*report_nr*/);
void ecl_util_memcpy_typed_data(void *, const void * , ecl_type_enum , ecl_type_enum , int );
void ecl_util_escape_kw(char * kw);
bool ecl_util_alloc_summary_files(const char * , const char * , const char * , char ** , stringlist_type * );
void ecl_util_alloc_summary_data_files(const char * path , const char * base , bool fmt_file , stringlist_type * filelist);
void ecl_util_alloc_restart_files(const char * , const char * , char *** , int * , bool * , bool *);
time_t ecl_util_get_start_date(const char * );
int ecl_util_get_num_cpu(const char * data_file);
bool ecl_util_fmt_file(const char *);
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);
bool ecl_util_valid_basename( const char * basename );
const char * ecl_util_get_phase_name( ecl_phase_enum phase );
const char * ecl_util_file_enum_iget( int index, int * value);
int ecl_util_select_filelist( const char * path , const char * base , ecl_file_enum file_type , bool fmt_file , stringlist_type * filelist);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,117 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'vector_template.h' 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.
*/
#ifndef __float_VECTOR_H__
#define __float_VECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <buffer.h>
#include <type_macros.h>
typedef struct float_vector_struct float_vector_type;
typedef float (float_ftype) (float);
int float_vector_lookup_bin( const float_vector_type * limits , float value , int guess);
int float_vector_lookup_bin__( const float_vector_type * limits , float value , int guess);
void float_vector_inplace_div( float_vector_type * vector , const float_vector_type * inv_factor);
void float_vector_inplace_mul( float_vector_type * vector , const float_vector_type * factor);
void float_vector_inplace_add( float_vector_type * vector , const float_vector_type * delta);
void float_vector_set_read_only( float_vector_type * vector , bool read_only);
bool float_vector_get_read_only( const float_vector_type * vector );
void float_vector_resize( float_vector_type * vector , int new_alloc_size );
void float_vector_memcpy_data( float * target, const float_vector_type * src );
void float_vector_memcpy( float_vector_type * target , const float_vector_type * src);
void float_vector_memcpy_data_block( float_vector_type * target , const float_vector_type * src , int target_offset , int src_offset , int len);
bool float_vector_growable( const float_vector_type * vector);
void float_vector_select_unique(float_vector_type * vector);
float_vector_type * float_vector_alloc( int init_size , float );
float_vector_type * float_vector_alloc_private_wrapper(int init_size, float default_value , float * data , int alloc_size);
float_vector_type * float_vector_alloc_shared_wrapper(int init_size, float default_value , float * data , int alloc_size);
float_vector_type * float_vector_alloc_strided_copy( const float_vector_type * src , int start , int stop , int stride );
float_vector_type * float_vector_alloc_copy( const float_vector_type * src);
void float_vector_imul(float_vector_type * vector, int index, float factor);
void float_vector_scale(float_vector_type * vector, float factor);
float float_vector_iget(const float_vector_type * , int);
float float_vector_safe_iget(const float_vector_type * , int);
float float_vector_get_min(const float_vector_type * vector);
float float_vector_get_max(const float_vector_type * vector);
int float_vector_get_min_index(const float_vector_type * vector, bool reverse);
int float_vector_get_max_index(const float_vector_type * vector, bool reverse);
float float_vector_iadd( float_vector_type * vector , int index , float delta);
void float_vector_iset(float_vector_type * , int , float);
void float_vector_idel_block( float_vector_type * vector , int index , int block_size);
float float_vector_idel( float_vector_type * vector , int index);
void float_vector_append(float_vector_type * , float);
void float_vector_free(float_vector_type *);
void float_vector_free__(void *);
void float_vector_free_data(float_vector_type *);
void float_vector_reset(float_vector_type *);
void float_vector_reset__(void * __vector);
int float_vector_size(const float_vector_type * );
float float_vector_pop(float_vector_type * vector);
float float_vector_get_first(const float_vector_type * vector);
float float_vector_get_last(const float_vector_type * );
float * float_vector_get_ptr(const float_vector_type * );
float * float_vector_alloc_data_copy( const float_vector_type * vector );
const float * float_vector_get_const_ptr(const float_vector_type * );
void float_vector_set_many(float_vector_type * , int , const float * , int );
void float_vector_set_all(float_vector_type * vector , float value);
void float_vector_append_many(float_vector_type * vector , const float * data , int length);
void float_vector_shrink(float_vector_type * );
float float_vector_sum(const float_vector_type * );
float float_vector_get_default(const float_vector_type * );
void float_vector_set_default(float_vector_type * vector, float default_value);
void float_vector_append_default(float_vector_type * vector , float default_value);
void float_vector_iset_default(float_vector_type * vector , int index , float default_value);
bool float_vector_is_sorted( const float_vector_type * vector , bool reverse);
int float_vector_index(const float_vector_type * vector , float value);
int float_vector_index_sorted(const float_vector_type * vector , float value);
void float_vector_sort(float_vector_type * vector);
void float_vector_rsort(float_vector_type * vector);
void float_vector_permute(float_vector_type * vector , const int * perm);
int * float_vector_alloc_sort_perm(const float_vector_type * vector);
int * float_vector_alloc_rsort_perm(const float_vector_type * vector);
void float_vector_fprintf(const float_vector_type * vector , FILE * stream , const char * name , const char * fmt);
void float_vector_fwrite(const float_vector_type * vector , FILE * stream);
void float_vector_buffer_fread(float_vector_type * vector , buffer_type * buffer);
float_vector_type * float_vector_fread_alloc( FILE * stream );
float_vector_type * float_vector_buffer_fread_alloc( buffer_type * buffer );
void float_vector_buffer_fwrite(const float_vector_type * vector , buffer_type * buffer);
void float_vector_fread( float_vector_type * vector , FILE * stream );
void float_vector_fwrite_data( const float_vector_type * vector , FILE * stream );
void float_vector_fread_data( float_vector_type * vector , int size, FILE * stream);
bool float_vector_equal(const float_vector_type * vector1 , const float_vector_type * vector2);
void float_vector_apply(float_vector_type * vector , float_ftype *func);
int float_vector_count_equal( const float_vector_type * vector , float cmp_value);
int float_vector_element_size( const float_vector_type * vector );
UTIL_SAFE_CAST_HEADER( float_vector );
#ifdef __cplusplus
}
#endif
#endif
//

View File

@ -1,46 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'geo_surface.h' 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.
*/
#ifndef __GEO_SURFACE_H__
#define __GEO_SURFACE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <geo_pointset.h>
typedef struct geo_surface_struct geo_surface_type;
void geo_surface_free( geo_surface_type * geo_surface );
void geo_surface_free__( void * arg);
geo_pointset_type * geo_surface_get_pointset( const geo_surface_type * surface );
geo_surface_type * geo_surface_fload_alloc_irap( const char * filename , bool loadz);
void geo_surface_fload_irap_zcoord( const geo_surface_type * surface, const char * filename, double *zlist);
int geo_surface_get_size( const geo_surface_type * surface );
void geo_surface_fprintf_irap( const geo_surface_type * surface, const char * filename );
void geo_surface_fprintf_irap_external_zcoord( const geo_surface_type * surface, const char * filename , const double * zcoord);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,85 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'hash.h' 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.
*/
#ifndef __HASH_H__
#define __HASH_H__
#ifdef __cplusplus
extern"C" {
#endif
#include <stdlib.h>
#include <stringlist.h>
#include <type_macros.h>
typedef struct hash_struct hash_type;
typedef struct hash_iter_struct hash_iter_type;
typedef void (hash_apply_ftype) (void * );
#include <hash_node.h>
void hash_lock (hash_type * );
void hash_unlock(hash_type * );
hash_type * hash_alloc();
hash_type * hash_alloc_unlocked();
hash_type * hash_safe_cast( void * arg);
void hash_iter_complete(hash_type * );
void hash_free(hash_type *);
void hash_free__(void *);
void hash_insert_ref(hash_type * , const char * , const void *);
void hash_insert_copy(hash_type *, const char * , const void *, copyc_ftype *, free_ftype *);
void hash_insert_string(hash_type *, const char *, const char *);
bool hash_has_key(const hash_type *, const char *);
void * hash_pop( hash_type * hash , const char * key);
void * hash_safe_get( const hash_type * hash , const char * key );
void * hash_get(const hash_type *, const char *);
char * hash_get_string(hash_type * , const char *);
void hash_del(hash_type *, const char *);
void hash_safe_del(hash_type * , const char * );
void hash_clear(hash_type *);
int hash_get_size(const hash_type *);
void hash_set_keylist(const hash_type * , char **);
char ** hash_alloc_keylist(hash_type *);
stringlist_type * hash_alloc_stringlist(hash_type * );
char ** hash_alloc_sorted_keylist (hash_type *hash , int ( hash_get_cmp_value ) (const void *));
char ** hash_alloc_key_sorted_list(hash_type *hash, int (*cmp)(const void *, const void *));
bool hash_key_list_compare( hash_type * hash1, hash_type * hash2);
void hash_insert_hash_owned_ref(hash_type *, const char * , const void *, free_ftype *);
void hash_resize(hash_type *hash, int new_size);
hash_iter_type * hash_iter_alloc(const hash_type *);
void hash_iter_free(hash_iter_type *);
bool hash_iter_is_complete(const hash_iter_type *);
const char * hash_iter_get_next_key(hash_iter_type *);
void * hash_iter_get_next_value(hash_iter_type *);
void hash_iter_restart( hash_iter_type * iter );
hash_type * hash_alloc_from_options(const stringlist_type *);
int hash_inc_counter(hash_type * hash , const char * counter_key);
int hash_get_counter(hash_type * hash , const char * key);
void hash_insert_int(hash_type * , const char * , int);
int hash_get_int(hash_type * , const char *);
void hash_insert_double(hash_type * , const char * , double);
double hash_get_double(hash_type * , const char *);
void hash_apply( hash_type * hash , hash_apply_ftype * func);
UTIL_IS_INSTANCE_HEADER(hash);
#ifdef __cplusplus
}
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More