Merge pull request #10 from OPM/internal

Internal
This commit is contained in:
Magne Sjaastad 2012-10-25 05:23:04 -07:00
commit 6432b69aff
84 changed files with 1590 additions and 503 deletions

View File

@ -111,6 +111,14 @@ RIApplication::RIApplication(int& argc, char** argv)
m_socketServer = new RiaSocketServer( this); m_socketServer = new RiaSocketServer( this);
m_workerProcess = NULL; m_workerProcess = NULL;
m_startupDefaultDirectory = QDir::homePath();
#ifdef WIN32
//m_startupDefaultDirectory += "/My Documents/";
#endif
} }
@ -119,6 +127,7 @@ RIApplication::RIApplication(int& argc, char** argv)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RIApplication::~RIApplication() RIApplication::~RIApplication()
{ {
delete m_preferences;
} }
@ -282,6 +291,8 @@ bool RIApplication::saveProjectPromptForFileName()
{ {
//if (m_project.isNull()) return true; //if (m_project.isNull()) return true;
RIApplication* app = RIApplication::instance();
QString startPath; QString startPath;
if (!m_project->fileName().isEmpty()) if (!m_project->fileName().isEmpty())
{ {
@ -290,7 +301,7 @@ bool RIApplication::saveProjectPromptForFileName()
} }
else else
{ {
startPath = QDir::currentPath(); startPath = app->defaultFileDialogDirectory("BINARY_GRID");
} }
startPath += "/ResInsightProject.rip"; startPath += "/ResInsightProject.rip";
@ -301,6 +312,9 @@ bool RIApplication::saveProjectPromptForFileName()
return false; return false;
} }
// Remember the directory to next time
app->setDefaultFileDialogDirectory("BINARY_GRID", QFileInfo(fileName).absolutePath());
bool bSaveOk = saveProjectAs(fileName); bool bSaveOk = saveProjectAs(fileName);
setWindowCaptionFromAppState(); setWindowCaptionFromAppState();
@ -591,38 +605,52 @@ bool RIApplication::parseArguments()
bool isParsingProjectFile = false; bool isParsingProjectFile = false;
bool isParsingCaseNames = false; bool isParsingCaseNames = false;
bool isParsingStartDir = false;
bool showHelp = false; bool showHelp = false;
int i; int i;
for (i = 1; i < arguments.size(); i++) for (i = 1; i < arguments.size(); i++)
{ {
QString arg = arguments[i]; QString arg = arguments[i];
bool argParsedAsFlag = false; bool foundKnownOption = false;
if (arg.toLower() == "-help" || arg.toLower() == "-?") if (arg.toLower() == "-help" || arg.toLower() == "-?")
{ {
showHelp = true; showHelp = true;
foundKnownOption = true;
} }
if (arg.toLower() == "-last") if (arg.toLower() == "-last")
{ {
openLatestProject = true; openLatestProject = true;
argParsedAsFlag = true; foundKnownOption = true;
} }
else if (arg.toLower() == "-project") else if (arg.toLower() == "-project")
{ {
isParsingCaseNames = false; isParsingCaseNames = false;
isParsingProjectFile = true; isParsingProjectFile = true;
argParsedAsFlag = true; isParsingStartDir = false;
foundKnownOption = true;
} }
else if (arg.toLower() == "-case") else if (arg.toLower() == "-case")
{ {
isParsingCaseNames = true; isParsingCaseNames = true;
isParsingProjectFile = false; isParsingProjectFile = false;
argParsedAsFlag = true; isParsingStartDir = false;
foundKnownOption = true;
}
else if (arg.toLower() == "-startdir")
{
isParsingCaseNames = false;
isParsingProjectFile = false;
isParsingStartDir = true;
foundKnownOption = true;
} }
if (!argParsedAsFlag) if (!foundKnownOption)
{ {
if (isParsingProjectFile && QFile::exists(arg)) if (isParsingProjectFile && QFile::exists(arg))
{ {
@ -633,6 +661,11 @@ bool RIApplication::parseArguments()
{ {
caseNames.append(arg); caseNames.append(arg);
} }
if (isParsingStartDir)
{
m_startupDefaultDirectory = arg;
}
} }
} }
@ -648,6 +681,8 @@ bool RIApplication::parseArguments()
"-project <filename> Open project file <filename>\n" "-project <filename> Open project file <filename>\n"
"-case <casename> Open Eclipse case <casename>\n" "-case <casename> Open Eclipse case <casename>\n"
" (do not include .GRID/.EGRID)\n" " (do not include .GRID/.EGRID)\n"
"-startdir The default directory for open/save commands\n"
"-help \n" "-help \n"
"-? Displays help text\n" "-? Displays help text\n"
"-----------------------------------------------------------------"; "-----------------------------------------------------------------";
@ -883,3 +918,28 @@ void RIApplication::terminateProcess()
m_workerProcess = NULL; m_workerProcess = NULL;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RIApplication::defaultFileDialogDirectory(const QString& dialogName)
{
QString defaultDirectory = m_startupDefaultDirectory;
std::map<QString, QString>::iterator it;
it = m_fileDialogDefaultDirectories.find(dialogName);
if ( it != m_fileDialogDefaultDirectories.end())
{
defaultDirectory = it->second;
}
return defaultDirectory;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::setDefaultFileDialogDirectory(const QString& dialogName, const QString& defaultDirectory)
{
m_fileDialogDefaultDirectories[dialogName] = defaultDirectory;
}

View File

@ -75,6 +75,9 @@ public:
void createLargeResultsMockModel(); void createLargeResultsMockModel();
void createInputMockModel(); void createInputMockModel();
QString defaultFileDialogDirectory(const QString& dialogName);
void setDefaultFileDialogDirectory(const QString& dialogName, const QString& defaultDirectory);
bool openEclipseCaseFromFile(const QString& fileName); bool openEclipseCaseFromFile(const QString& fileName);
bool openEclipseCase(const QString& caseName, const QString& caseFileName); bool openEclipseCase(const QString& caseName, const QString& caseFileName);
bool openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames); bool openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames);
@ -129,4 +132,7 @@ private:
caf::UiProcess* m_workerProcess; caf::UiProcess* m_workerProcess;
RIPreferences* m_preferences; RIPreferences* m_preferences;
std::map<QString, QString> m_fileDialogDefaultDirectories;
QString m_startupDefaultDirectory;
}; };

View File

@ -37,13 +37,17 @@ RIPreferences::RIPreferences(void)
CAF_PDM_InitField(&octaveExecutable, "octaveExecutable", QString("octave"), "Octave", "", "", ""); CAF_PDM_InitField(&octaveExecutable, "octaveExecutable", QString("octave"), "Octave", "", "", "");
octaveExecutable.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); octaveExecutable.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitField(&defaultGridLines, "defaultGridLines", true, "Gridlines", "", "", "");
CAF_PDM_InitField(&defaultScaleFactorZ, "defaultScaleFactorZ", 5, "Z scale factor", "", "", "");
CAF_PDM_InitField(&useShaders, "useShaders", true, "Use Shaders", "", "", ""); CAF_PDM_InitField(&useShaders, "useShaders", true, "Use Shaders", "", "", "");
CAF_PDM_InitField(&showHud, "showHud", true, "Show 3D Information", "", "", ""); CAF_PDM_InitField(&showHud, "showHud", false, "Show 3D Information", "", "", "");
CAF_PDM_InitFieldNoDefault(&lastUsedProjectFileName,"lastUsedProjectFileName", "Last Used Project File", "", "", ""); CAF_PDM_InitFieldNoDefault(&lastUsedProjectFileName,"lastUsedProjectFileName", "Last Used Project File", "", "", "");
lastUsedProjectFileName.setUiHidden(true); lastUsedProjectFileName.setUiHidden(true);
CAF_PDM_InitField(&autocomputeSOIL, "autocomputeSOIL", true, "Compute SOIL if not on disk", "", "", ""); CAF_PDM_InitField(&autocomputeSOIL, "autocomputeSOIL", true, "SOIL", "", "SOIL = 1.0 - SGAS - SWAT", "");
CAF_PDM_InitField(&autocomputeDepthRelatedProperties,"autocomputeDepth", true, "DEPTH related properties", "", "DEPTH, DX, DY, DZ, TOP, BOTTOM", "");
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -69,3 +73,24 @@ void RIPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QStr
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const
{
uiOrdering.add(&navigationPolicy);
caf::PdmUiGroup* scriptGroup = uiOrdering.addNewGroup("Script configuration");
scriptGroup->add(&scriptDirectory);
scriptGroup->add(&scriptEditorExecutable);
scriptGroup->add(&octaveExecutable);
caf::PdmUiGroup* defaultSettingsGroup = uiOrdering.addNewGroup("Default settings");
defaultSettingsGroup->add(&defaultScaleFactorZ);
defaultSettingsGroup->add(&defaultGridLines);
caf::PdmUiGroup* autoComputeGroup = uiOrdering.addNewGroup("Compute when loading new case");
autoComputeGroup->add(&autocomputeSOIL);
autoComputeGroup->add(&autocomputeDepthRelatedProperties);
}

View File

@ -36,14 +36,20 @@ public: // Pdm Fields
caf::PdmField<QString> scriptEditorExecutable; caf::PdmField<QString> scriptEditorExecutable;
caf::PdmField<QString> octaveExecutable; caf::PdmField<QString> octaveExecutable;
caf::PdmField<int> defaultScaleFactorZ;
caf::PdmField<bool> defaultGridLines;
caf::PdmField<bool> useShaders; caf::PdmField<bool> useShaders;
caf::PdmField<bool> showHud; caf::PdmField<bool> showHud;
caf::PdmField<QString> lastUsedProjectFileName; caf::PdmField<QString> lastUsedProjectFileName;
caf::PdmField<bool> autocomputeSOIL; caf::PdmField<bool> autocomputeSOIL;
caf::PdmField<bool> autocomputeDepthRelatedProperties;
protected: protected:
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const;
}; };

View File

@ -29,6 +29,7 @@
#include <QFile> #include <QFile>
#include <QTextStream> #include <QTextStream>
#include <QDebug>
#ifdef USE_ECL_LIB #ifdef USE_ECL_LIB
#include "ecl_grid.h" #include "ecl_grid.h"
@ -38,6 +39,8 @@
#include <fstream> #include <fstream>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Constructor /// Constructor
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -63,6 +66,20 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoi
{ {
CVF_ASSERT(reservoir); CVF_ASSERT(reservoir);
qint64 coordPos = -1;
qint64 zcornPos = -1;
qint64 specgridPos = -1;
qint64 actnumPos = -1;
qint64 mapaxesPos = -1;
findGridKeywordPositions(fileName, &coordPos, &zcornPos, &specgridPos, &actnumPos, &mapaxesPos);
if (coordPos < 0 || zcornPos < 0 || specgridPos < 0)
{
return false;
}
FILE* gridFilePointer = util_fopen(fileName.toLatin1().data(), "r"); FILE* gridFilePointer = util_fopen(fileName.toLatin1().data(), "r");
if (!gridFilePointer) return false; if (!gridFilePointer) return false;
@ -74,6 +91,8 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoi
//ecl_kw_type * ecl_kw_fscanf_alloc_grdecl_dynamic__( FILE * stream , const char * kw , bool strict , ecl_type_enum ecl_type); //ecl_kw_type * ecl_kw_fscanf_alloc_grdecl_dynamic__( FILE * stream , const char * kw , bool strict , ecl_type_enum ecl_type);
//ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw ); //ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw );
ecl_kw_type* specGridKw = NULL; ecl_kw_type* specGridKw = NULL;
ecl_kw_type* zCornKw = NULL; ecl_kw_type* zCornKw = NULL;
ecl_kw_type* coordKw = NULL; ecl_kw_type* coordKw = NULL;
@ -82,19 +101,38 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoi
// Try to read all the needed keywords. Early exit if some are not found // Try to read all the needed keywords. Early exit if some are not found
caf::ProgressInfo progress(7, "Read Grid from Eclipse Input file"); caf::ProgressInfo progress(7, "Read Grid from Eclipse Input file");
bool allKwReadOk = true;
allKwReadOk = allKwReadOk && NULL != (specGridKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "SPECGRID" , false , ECL_INT_TYPE));
bool allKwReadOk = true;
bool continueReading = true;
fseek(gridFilePointer, specgridPos, SEEK_SET);
allKwReadOk = allKwReadOk && NULL != (specGridKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_INT_TYPE));
progress.setProgress(1); progress.setProgress(1);
allKwReadOk = allKwReadOk && NULL != (zCornKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "ZCORN" , false , ECL_FLOAT_TYPE));
fseek(gridFilePointer, zcornPos, SEEK_SET);
allKwReadOk = allKwReadOk && NULL != (zCornKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_FLOAT_TYPE));
progress.setProgress(2); progress.setProgress(2);
allKwReadOk = allKwReadOk && NULL != (coordKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "COORD" , false , ECL_FLOAT_TYPE));
fseek(gridFilePointer, coordPos, SEEK_SET);
allKwReadOk = allKwReadOk && NULL != (coordKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_FLOAT_TYPE));
progress.setProgress(3); progress.setProgress(3);
allKwReadOk = allKwReadOk && NULL != (actNumKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "ACTNUM" , false , ECL_INT_TYPE));
// If ACTNUM is not defined, this pointer will be NULL, which is a valid condition
if (actnumPos >= 0)
{
fseek(gridFilePointer, actnumPos, SEEK_SET);
allKwReadOk = allKwReadOk && NULL != (actNumKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_INT_TYPE));
progress.setProgress(4); progress.setProgress(4);
}
// If MAPAXES is not defined, this pointer will be NULL, which is a valid condition // If MAPAXES is not defined, this pointer will be NULL, which is a valid condition
mapAxesKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "MAPAXES" , false , ECL_FLOAT_TYPE); if (mapaxesPos >= 0)
{
fseek(gridFilePointer, mapaxesPos, SEEK_SET);
mapAxesKw = ecl_kw_fscanf_alloc_current_grdecl__( gridFilePointer, false , ECL_FLOAT_TYPE);
}
if (!allKwReadOk) if (!allKwReadOk)
{ {
@ -125,7 +163,7 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoi
ecl_kw_free(specGridKw); ecl_kw_free(specGridKw);
ecl_kw_free(zCornKw); ecl_kw_free(zCornKw);
ecl_kw_free(coordKw); ecl_kw_free(coordKw);
ecl_kw_free(actNumKw); if (actNumKw) ecl_kw_free(actNumKw);
if (mapAxesKw) ecl_kw_free(mapAxesKw); if (mapAxesKw) ecl_kw_free(mapAxesKw);
ecl_grid_free(inputGrid); ecl_grid_free(inputGrid);
@ -152,7 +190,7 @@ std::map<QString, QString> RifEclipseInputFileTools::readProperties(const QStri
caf::ProgressInfo mainProgress(2, "Reading Eclipse Input properties"); caf::ProgressInfo mainProgress(2, "Reading Eclipse Input properties");
caf::ProgressInfo startProgress(knownKeywordSet.size(), "Scanning for known properties"); caf::ProgressInfo startProgress(knownKeywordSet.size(), "Scanning for known properties");
std::vector<QString> fileKeywords = RifEclipseInputFileTools::findKeywordsOnFile(fileName); std::vector<RifKeywordAndFilePos> fileKeywords = RifEclipseInputFileTools::findKeywordsOnFile(fileName);
mainProgress.setProgress(1); mainProgress.setProgress(1);
caf::ProgressInfo progress(fileKeywords.size(), "Reading properties"); caf::ProgressInfo progress(fileKeywords.size(), "Reading properties");
@ -168,13 +206,14 @@ std::map<QString, QString> RifEclipseInputFileTools::readProperties(const QStri
std::map<QString, QString> newResults; std::map<QString, QString> newResults;
for (size_t i = 0; i < fileKeywords.size(); ++i) for (size_t i = 0; i < fileKeywords.size(); ++i)
{ {
std::cout << fileKeywords[i].toLatin1().data() << std::endl; //std::cout << fileKeywords[i].keyword.toLatin1().data() << std::endl;
if (knownKeywordSet.count(fileKeywords[i])) if (knownKeywordSet.count(fileKeywords[i].keyword))
{ {
ecl_kw_type* eclKeyWordData = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , fileKeywords[i].toLatin1().data() , false , ECL_FLOAT_TYPE); fseek(gridFilePointer, fileKeywords[i].filePos, SEEK_SET);
ecl_kw_type* eclKeyWordData = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_FLOAT_TYPE);
if (eclKeyWordData) if (eclKeyWordData)
{ {
QString newResultName = reservoir->mainGrid()->results()->makeResultNameUnique(fileKeywords[i]); QString newResultName = reservoir->mainGrid()->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()->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); // Should really merge with inputProperty object information because we need to use PropertyName, and not keyword
@ -184,7 +223,7 @@ std::map<QString, QString> RifEclipseInputFileTools::readProperties(const QStri
ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data()); ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data());
ecl_kw_free(eclKeyWordData); ecl_kw_free(eclKeyWordData);
newResults[newResultName] = fileKeywords[i]; newResults[newResultName] = fileKeywords[i].keyword;
} }
} }
progress.setProgress(i); progress.setProgress(i);
@ -196,45 +235,47 @@ std::map<QString, QString> RifEclipseInputFileTools::readProperties(const QStri
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Read all the keywords from a file /// Read all the keywords from a file
//
// This code was originally written using QTextStream, but due to a bug in Qt version up to 4.8.0
// we had to implement the reading using QFile and QFile::readLine
//
// See:
// https://bugreports.qt-project.org/browse/QTBUG-9814
//
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<QString> RifEclipseInputFileTools::findKeywordsOnFile(const QString &fileName) std::vector< RifKeywordAndFilePos > RifEclipseInputFileTools::findKeywordsOnFile(const QString &fileName)
{ {
std::vector<QString> keywords; std::vector< RifKeywordAndFilePos > keywords;
std::ifstream is(fileName.toLatin1().data()); char buf[1024];
while (is) QFile data(fileName);
data.open(QFile::ReadOnly);
QString line;
qint64 filepos = -1;
qint64 lineLength = -1;
do
{ {
std::string word; lineLength = data.readLine(buf, sizeof(buf));
is >> word; if (lineLength > 0)
if (word.size() && isalpha(word[0]))
{ {
keywords.push_back(word.c_str()); line = QString::fromAscii(buf);
if (line.size() && line[0].isLetter())
{
RifKeywordAndFilePos keyPos;
filepos = data.pos() - lineLength;
keyPos.filePos = filepos;
keyPos.keyword = line.left(8).trimmed();
keywords.push_back(keyPos);
//qDebug() << keyPos.keyword << " - " << keyPos.filePos;
} }
is.ignore(20000, '\n');
} }
is.close();
/*
FILE* gridFilePointer = util_fopen(fileName.toLatin1().data(), "r");
if (!gridFilePointer) return keywords;
char * keyWordString = NULL;
keyWordString = ecl_kw_grdecl_alloc_next_header(gridFilePointer);
while(keyWordString)
{
keywords.push_back(keyWordString);
util_realloc(keyWordString, 0, "RifEclipseInputFileTools::findKeywordsOnFile");
keyWordString = ecl_kw_grdecl_alloc_next_header(gridFilePointer);
} }
while (lineLength != -1);
util_fclose(gridFilePointer);
*/
return keywords; return keywords;
} }
@ -434,3 +475,73 @@ void RifEclipseInputFileTools::writeDataToTextFile(QFile* file, const QString& e
out << "\n" << "/" << "\n"; out << "\n" << "/" << "\n";
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseInputFileTools::findGridKeywordPositions(const QString& filename, qint64* coordPos, qint64* zcornPos, qint64* specgridPos, qint64* actnumPos, qint64* mapaxesPos)
{
CVF_ASSERT(coordPos && zcornPos && specgridPos && actnumPos && mapaxesPos);
std::vector< RifKeywordAndFilePos > keywordsAndFilePos = findKeywordsOnFile(filename);
size_t i;
for (i = 0; i < keywordsAndFilePos.size(); i++)
{
if (keywordsAndFilePos[i].keyword == "COORD")
{
*coordPos = keywordsAndFilePos[i].filePos;
}
else if (keywordsAndFilePos[i].keyword == "ZCORN")
{
*zcornPos = keywordsAndFilePos[i].filePos;
}
else if (keywordsAndFilePos[i].keyword == "SPECGRID")
{
*specgridPos = keywordsAndFilePos[i].filePos;
}
else if (keywordsAndFilePos[i].keyword == "ACTNUM")
{
*actnumPos = keywordsAndFilePos[i].filePos;
}
else if (keywordsAndFilePos[i].keyword == "MAPAXES")
{
*mapaxesPos = keywordsAndFilePos[i].filePos;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifEclipseInputFileTools::readPropertyAtFilePosition(const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName)
{
CVF_ASSERT(reservoir);
FILE* filePointer = util_fopen(fileName.toLatin1().data(), "r");
if (!filePointer) return false;
fseek(filePointer, filePos, SEEK_SET);
ecl_kw_type* eclKeyWordData = ecl_kw_fscanf_alloc_current_grdecl__(filePointer, false , ECL_FLOAT_TYPE);
bool isOk = false;
if (eclKeyWordData)
{
QString newResultName = resultName;
size_t resultIndex = reservoir->mainGrid()->results()->findScalarResultIndex(newResultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
{
resultIndex = reservoir->mainGrid()->results()->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName);
}
std::vector< std::vector<double> >& newPropertyData = reservoir->mainGrid()->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());
isOk = true;
ecl_kw_free(eclKeyWordData);
}
util_fclose(filePointer);
return isOk;
}

View File

@ -23,10 +23,23 @@
#include "cvfLibCore.h" #include "cvfLibCore.h"
#include <map> #include <map>
#include <QString>
class RigReservoir; class RigReservoir;
class QString;
class QFile; class QFile;
//--------------------------------------------------------------------------------------------------
/// Structure used to cache file position of keywords
//--------------------------------------------------------------------------------------------------
struct RifKeywordAndFilePos
{
QString keyword;
qint64 filePos;
};
//================================================================================================== //==================================================================================================
// //
// Class for access to Eclipse "keyword" files using libecl // Class for access to Eclipse "keyword" files using libecl
@ -43,7 +56,9 @@ public:
// Returns map of assigned resultName and Eclipse Keyword. // Returns map of assigned resultName and Eclipse Keyword.
static std::map<QString, QString> readProperties(const QString& fileName, RigReservoir* reservoir); static std::map<QString, QString> readProperties(const QString& fileName, RigReservoir* reservoir);
static bool readProperty (const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, const QString& resultName ); static bool readProperty (const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, const QString& resultName );
static std::vector<QString> findKeywordsOnFile(const QString &fileName); static bool readPropertyAtFilePosition (const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName );
static std::vector< RifKeywordAndFilePos > findKeywordsOnFile(const QString &fileName);
static const std::vector<QString>& knownPropertyKeywords(); static const std::vector<QString>& knownPropertyKeywords();
@ -52,4 +67,5 @@ public:
private: private:
static void writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector<double>& resultData); static void writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector<double>& resultData);
static void findGridKeywordPositions(const QString& filename, qint64* coordPos, qint64* zcornPos, qint64* specgridPos, qint64* actnumPos, qint64* mapaxesPos);
}; };

View File

@ -99,7 +99,7 @@ void Rim3dOverlayInfoConfig::update3DInfo()
QString infoText = QString( QString infoText = QString(
"<p><b><center>-- %1 --</center></b><p> " "<p><b><center>-- %1 --</center></b><p> "
"<b>Cell count:</b> Total: %2 Active: %3 <br>" "<b>Cell count. Total:</b> %2 <b>Active:</b> %3 <br>"
"<b>Main Grid I,J,K:</b> %4, %5, %6 <br>").arg(caseName, totCellCount, activeCellCount, iSize, jSize, kSize); "<b>Main Grid I,J,K:</b> %4, %5, %6 <br>").arg(caseName, totCellCount, activeCellCount, iSize, jSize, kSize);
if (m_reservoirView->animationMode() && m_reservoirView->cellResult()->hasResult()) if (m_reservoirView->animationMode() && m_reservoirView->cellResult()->hasResult())
@ -108,11 +108,16 @@ void Rim3dOverlayInfoConfig::update3DInfo()
double min, max; double min, max;
double p10, p90; double p10, p90;
double mean;
size_t scalarIndex = m_reservoirView->cellResult()->gridScalarIndex(); size_t scalarIndex = m_reservoirView->cellResult()->gridScalarIndex();
m_reservoirView->gridCellResults()->minMaxCellScalarValues(scalarIndex, min, max); m_reservoirView->gridCellResults()->minMaxCellScalarValues(scalarIndex, min, max);
m_reservoirView->gridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); m_reservoirView->gridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90);
m_reservoirView->gridCellResults()->meanCellScalarValues(scalarIndex, mean);
infoText += QString("<blockquote> Min: %1 P10: %2 P90: %3 Max: %4 </blockquote>").arg(min).arg(p10).arg(p90).arg(max); //infoText += QString("<blockquote><b>Min:</b> %1 <b>P10:</b> %2 <b>Mean:</b> %3 <b>P90:</b> %4 <b>Max:</b> %5 </blockquote>").arg(min).arg(p10).arg(mean).arg(p90).arg(max);
//infoText += QString("<blockquote><pre>Min: %1 P10: %2 Mean: %3 \n P90: %4 Max: %5 </pre></blockquote>").arg(min).arg(p10).arg(mean).arg(p90).arg(max);
infoText += QString("<table border=0 cellspacing=5 ><tr><td>Min</td><td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> </tr>"
"<tr><td>%1</td><td> %2</td><td> %3</td><td> %4</td><td> %5 </td></tr></table>").arg(min).arg(p10).arg(mean).arg(p90).arg(max);
} }
@ -142,13 +147,16 @@ void Rim3dOverlayInfoConfig::update3DInfo()
{ {
double min, max; double min, max;
double p10, p90; double p10, p90;
double mean;
size_t scalarIndex = m_reservoirView->cellResult()->gridScalarIndex(); size_t scalarIndex = m_reservoirView->cellResult()->gridScalarIndex();
m_reservoirView->gridCellResults()->minMaxCellScalarValues(scalarIndex, min, max); m_reservoirView->gridCellResults()->minMaxCellScalarValues(scalarIndex, min, max);
m_reservoirView->gridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); m_reservoirView->gridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90);
m_reservoirView->gridCellResults()->meanCellScalarValues(scalarIndex, mean);
m_reservoirView->viewer()->showHistogram(true); m_reservoirView->viewer()->showHistogram(true);
m_reservoirView->viewer()->setHistogram(min, max, m_reservoirView->gridCellResults()->cellScalarValuesHistogram(scalarIndex)); m_reservoirView->viewer()->setHistogram(min, max, m_reservoirView->gridCellResults()->cellScalarValuesHistogram(scalarIndex));
m_reservoirView->viewer()->setHistogramPercentiles(p10, p90); m_reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean);
} }
} }
} }

View File

@ -299,8 +299,6 @@ void RimCellEdgeResultSlot::updateIgnoredScalarValue()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimCellEdgeResultSlot::minMaxCellEdgeValues(double& min, double& max) void RimCellEdgeResultSlot::minMaxCellEdgeValues(double& min, double& max)
{ {
CVF_ASSERT(min && max);
double globalMin, globalMax; double globalMin, globalMax;
globalMin = HUGE_VAL; globalMin = HUGE_VAL;
globalMax = -HUGE_VAL; globalMax = -HUGE_VAL;

View File

@ -24,6 +24,7 @@
#include "RigGridBase.h" #include "RigGridBase.h"
#include "RigReservoirCellResults.h" #include "RigReservoirCellResults.h"
#include "cafPdmUiDoubleSliderEditor.h"
@ -65,9 +66,15 @@ RimCellPropertyFilter::RimCellPropertyFilter()
resultDefinition.setUiHidden(true); resultDefinition.setUiHidden(true);
CAF_PDM_InitField(&lowerBound, "LowerBound", 0.0, "Min", "", "", ""); CAF_PDM_InitField(&lowerBound, "LowerBound", 0.0, "Min", "", "", "");
lowerBound.setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
CAF_PDM_InitField(&upperBound, "UpperBound", 0.0, "Max", "", "", ""); CAF_PDM_InitField(&upperBound, "UpperBound", 0.0, "Max", "", "", "");
upperBound.setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
updateIconState(); updateIconState();
m_minimumResultValue = cvf::UNDEFINED_DOUBLE;
m_maximumResultValue = cvf::UNDEFINED_DOUBLE;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -148,6 +155,9 @@ void RimCellPropertyFilter::setDefaultValues()
upperBound = max; upperBound = max;
upperBound.setUiName(QString("Max (%1)").arg(max)); upperBound.setUiName(QString("Max (%1)").arg(max));
m_maximumResultValue = max;
m_minimumResultValue = min;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -173,3 +183,26 @@ void RimCellPropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd
uiOrdering.add(&filterMode); uiOrdering.add(&filterMode);
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellPropertyFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{
if (m_minimumResultValue == cvf::UNDEFINED_DOUBLE || m_maximumResultValue == cvf::UNDEFINED_DOUBLE)
{
return;
}
if (field == &lowerBound || field == &upperBound)
{
caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>(attribute);
if (!myAttr)
{
return;
}
myAttr->m_minimum = m_minimumResultValue;
myAttr->m_maximum = m_maximumResultValue;
}
}

View File

@ -73,9 +73,11 @@ public:
protected: protected:
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const;
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
private: private:
RimCellPropertyFilterCollection* m_parentContainer; RimCellPropertyFilterCollection* m_parentContainer;
double m_minimumResultValue, m_maximumResultValue;
}; };

View File

@ -34,6 +34,10 @@
#include "RifEclipseInputFileTools.h" #include "RifEclipseInputFileTools.h"
#include "cafProgressInfo.h" #include "cafProgressInfo.h"
#include "RIApplication.h"
#include "RIPreferences.h"
CAF_PDM_SOURCE_INIT(RimInputReservoir, "RimInputReservoir"); CAF_PDM_SOURCE_INIT(RimInputReservoir, "RimInputReservoir");
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@ -150,8 +154,8 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames)
bool RimInputReservoir::openEclipseGridFile() bool RimInputReservoir::openEclipseGridFile()
{ {
// Early exit if reservoir data is created // Early exit if reservoir data is created
if (m_rigReservoir.notNull()) return true; if (m_rigReservoir.isNull())
{
cvf::ref<RifReaderInterface> readerInterface; cvf::ref<RifReaderInterface> readerInterface;
if (caseName().contains("Input Mock Debug Model")) if (caseName().contains("Input Mock Debug Model"))
@ -178,6 +182,14 @@ bool RimInputReservoir::openEclipseGridFile()
m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p()); m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p());
m_rigReservoir->computeFaults(); m_rigReservoir->computeFaults();
m_rigReservoir->mainGrid()->computeCachedData(); m_rigReservoir->mainGrid()->computeCachedData();
}
RigReservoirCellResults* results = m_rigReservoir->mainGrid()->results();
RIApplication* app = RIApplication::instance();
if (app->preferences()->autocomputeDepthRelatedProperties)
{
results->computeDepthRelatedResults();
}
return true; return true;
} }
@ -220,8 +232,8 @@ void RimInputReservoir::loadAndSyncronizeInputProperties()
if (isExistingFile) if (isExistingFile)
{ {
std::vector<QString> fileKeywords = RifEclipseInputFileTools::findKeywordsOnFile(filenames[i]); std::vector< RifKeywordAndFilePos > fileKeywords = RifEclipseInputFileTools::findKeywordsOnFile(filenames[i]);
for_all(fileKeywords, fkIt) fileKeywordSet.insert(fileKeywords[fkIt]); for_all(fileKeywords, fkIt) fileKeywordSet.insert(fileKeywords[fkIt].keyword);
} }
// Find the input property objects referring to the file // Find the input property objects referring to the file

View File

@ -50,6 +50,7 @@ template<>
void caf::AppEnum< RimReservoirView::MeshModeType >::setUp() void caf::AppEnum< RimReservoirView::MeshModeType >::setUp()
{ {
addItem(RimReservoirView::FULL_MESH, "FULL_MESH", "All"); addItem(RimReservoirView::FULL_MESH, "FULL_MESH", "All");
addItem(RimReservoirView::FAULTS_MESH, "FAULTS_MESH", "Faults only");
addItem(RimReservoirView::NO_MESH, "NO_MESH", "None"); addItem(RimReservoirView::NO_MESH, "NO_MESH", "None");
setDefault(RimReservoirView::FULL_MESH); setDefault(RimReservoirView::FULL_MESH);
} }
@ -58,7 +59,7 @@ template<>
void caf::AppEnum< RimReservoirView::SurfaceModeType >::setUp() void caf::AppEnum< RimReservoirView::SurfaceModeType >::setUp()
{ {
addItem(RimReservoirView::SURFACE, "SURFACE", "All"); addItem(RimReservoirView::SURFACE, "SURFACE", "All");
addItem(RimReservoirView::FAULTS, "FAULTS", "Faults"); addItem(RimReservoirView::FAULTS, "FAULTS", "Faults only");
addItem(RimReservoirView::NO_SURFACE, "NO_SURFACE", "None"); addItem(RimReservoirView::NO_SURFACE, "NO_SURFACE", "None");
setDefault(RimReservoirView::SURFACE); setDefault(RimReservoirView::SURFACE);
} }
@ -80,6 +81,10 @@ CAF_PDM_SOURCE_INIT(RimReservoirView, "ReservoirView");
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimReservoirView::RimReservoirView() RimReservoirView::RimReservoirView()
{ {
RIApplication* app = RIApplication::instance();
RIPreferences* preferences = app->preferences();
CVF_ASSERT(preferences);
CAF_PDM_InitObject("Reservoir View", ":/ReservoirView.png", "", ""); CAF_PDM_InitObject("Reservoir View", ":/ReservoirView.png", "", "");
CAF_PDM_InitFieldNoDefault(&cellResult, "GridCellResult", "Cell Result", ":/CellResult.png", "", ""); CAF_PDM_InitFieldNoDefault(&cellResult, "GridCellResult", "Cell Result", ":/CellResult.png", "", "");
@ -93,7 +98,11 @@ RimReservoirView::RimReservoirView()
overlayInfoConfig->setReservoirView(this); overlayInfoConfig->setReservoirView(this);
CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", ""); CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", "");
CAF_PDM_InitField(&scaleZ, "GridZScale", 1.0, "Z Scale", "", "Scales the scene in the Z direction", "");
double defaultScaleFactor = 1.0;
if (preferences) defaultScaleFactor = preferences->defaultScaleFactorZ;
CAF_PDM_InitField(&scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", "");
CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show 3D viewer", "", "", ""); CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show 3D viewer", "", "", "");
showWindow.setUiHidden(true); showWindow.setUiHidden(true);
@ -114,7 +123,9 @@ RimReservoirView::RimReservoirView()
propertyFilterCollection = new RimCellPropertyFilterCollection(); propertyFilterCollection = new RimCellPropertyFilterCollection();
propertyFilterCollection->setReservoirView(this); propertyFilterCollection->setReservoirView(this);
CAF_PDM_InitFieldNoDefault(&meshMode, "MeshMode", "Grid lines", "", "", ""); caf::AppEnum<RimReservoirView::MeshModeType> defaultMeshType = NO_MESH;
if (preferences->defaultGridLines) defaultMeshType = FULL_MESH;
CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid lines", "", "", "");
CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid surface", "", "", ""); CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid surface", "", "", "");
CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum frame rate","", "", ""); CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum frame rate","", "", "");
@ -153,6 +164,7 @@ RimReservoirView::~RimReservoirView()
delete rangeFilterCollection(); delete rangeFilterCollection();
delete propertyFilterCollection(); delete propertyFilterCollection();
delete wellCollection();
if (m_viewer) if (m_viewer)
{ {
@ -871,34 +883,29 @@ void RimReservoirView::updateDisplayModelVisibility()
{ {
if (m_viewer.isNull()) return; if (m_viewer.isNull()) return;
bool surfaceVisible = false; // Initialize the mask to show everything except the the bits controlled here
bool faultVisible = false; unsigned int mask = 0xffffffff & ~surfaceBit & ~faultBit & ~meshSurfaceBit & ~meshFaultBit ;
// Then turn the appropriate bits on according to the user settings
if (surfaceMode == SURFACE) if (surfaceMode == SURFACE)
{ {
surfaceVisible = true; mask |= surfaceBit;
faultVisible = true; mask |= faultBit;
} }
else if (surfaceMode == FAULTS) else if (surfaceMode == FAULTS)
{ {
faultVisible = true; mask |= faultBit;
} }
unsigned int mask = 0;
if (meshMode == FULL_MESH) if (meshMode == FULL_MESH)
{ {
if (surfaceVisible) mask |= meshSurfaceBit; mask |= meshSurfaceBit;
if (faultVisible) mask |= meshFaultBit; mask |= meshFaultBit;
} }
else if (meshMode == FAULTS_MESH)
if (surfaceVisible)
{ {
mask |= surfaceBit; mask |= meshFaultBit;
}
if (faultVisible)
{
mask |= faultBit;
} }
m_viewer->setEnableMask(mask); m_viewer->setEnableMask(mask);

View File

@ -73,6 +73,7 @@ public:
enum MeshModeType enum MeshModeType
{ {
FULL_MESH, FULL_MESH,
FAULTS_MESH,
NO_MESH NO_MESH
}; };

View File

@ -201,6 +201,28 @@ bool RimUiTreeModelPdm::deleteReservoirView(const QModelIndex& itemIndex)
return true; return true;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeModelPdm::deleteReservoir(const QModelIndex& itemIndex)
{
CVF_ASSERT(itemIndex.isValid());
caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(itemIndex);
CVF_ASSERT(uiItem);
RimReservoir* reservoir = dynamic_cast<RimReservoir*>(uiItem->dataObject().p());
CVF_ASSERT(reservoir);
// Remove Ui items pointing at the pdm object to delete
removeRow(itemIndex.row(), itemIndex.parent());
RimProject* proj = RIApplication::instance()->project();
proj->reservoirs().removeChildObject(reservoir);
delete reservoir;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -419,3 +441,4 @@ void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex)
delete inputProperty; delete inputProperty;
} }

View File

@ -48,6 +48,7 @@ public:
bool deletePropertyFilter(const QModelIndex& itemIndex); bool deletePropertyFilter(const QModelIndex& itemIndex);
bool deleteReservoirView(const QModelIndex& itemIndex); bool deleteReservoirView(const QModelIndex& itemIndex);
void deleteInputProperty(const QModelIndex& itemIndex); void deleteInputProperty(const QModelIndex& itemIndex);
void deleteReservoir(const QModelIndex& itemIndex);
RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);

View File

@ -133,13 +133,19 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event)
{ {
QMenu menu; QMenu menu;
menu.addAction(QString("Delete"), this, SLOT(slotDeleteObjectFromContainer())); menu.addAction(QString("Delete"), this, SLOT(slotDeleteObjectFromContainer()));
menu.addAction(QString("Write"), this, SLOT(slotWriteInputProperty())); menu.addAction(QString("Save Property To File"), this, SLOT(slotWriteInputProperty()));
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
else if (dynamic_cast<RimResultSlot*>(uiItem->dataObject().p())) else if (dynamic_cast<RimResultSlot*>(uiItem->dataObject().p()))
{ {
QMenu menu; QMenu menu;
menu.addAction(QString("Write"), this, SLOT(slotWriteBinaryResultAsInputProperty())); menu.addAction(QString("Save Property To File"), this, SLOT(slotWriteBinaryResultAsInputProperty()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimReservoir*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("Close"), this, SLOT(slotCloseCase()));
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
} }
@ -452,7 +458,26 @@ void RimUiTreeView::slotExecuteScript()
QString octavePath = app->octavePath(); QString octavePath = app->octavePath();
if (!octavePath.isEmpty()) if (!octavePath.isEmpty())
{ {
// http://www.gnu.org/software/octave/doc/interpreter/Command-Line-Options.html#Command-Line-Options
// -p path
// Add path to the head of the search path for function files. The value of path specified on the command line
// will override any value of OCTAVE_PATH found in the environment, but not any commands in the system or
// user startup files that set the internal load path through one of the path functions.
// -q
// Don't print the usual greeting and version message at startup.
// TODO: Must rename RimCalcScript::absolutePath to absoluteFileName, as the code below is confusing
// absolutePath() is a function in QFileInfo
QFileInfo fi(calcScript->absolutePath());
QString octaveFunctionSearchPath = fi.absolutePath();
QStringList arguments; QStringList arguments;
arguments.append("--path");
arguments << octaveFunctionSearchPath;
arguments.append("-q"); arguments.append("-q");
arguments << calcScript->absolutePath(); arguments << calcScript->absolutePath();
@ -539,9 +564,17 @@ void RimUiTreeView::setModel(QAbstractItemModel* model)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotAddInputProperty() void RimUiTreeView::slotAddInputProperty()
{ {
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Eclipse Input Property Files", NULL, "All Files (*.* *)"); RIApplication* app = RIApplication::instance();
QString defaultDir = app->defaultFileDialogDirectory("INPUT_FILES");
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Eclipse Input Property Files", defaultDir, "All Files (*.* *)");
if (fileNames.isEmpty()) return; if (fileNames.isEmpty()) return;
// Remember the directory to next time
defaultDir = QFileInfo(fileNames.last()).absolutePath();
app->setDefaultFileDialogDirectory("INPUT_FILES", defaultDir);
QModelIndex index = currentIndex(); QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model()); RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
@ -702,3 +735,15 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotCloseCase()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
myModel->deleteReservoir(currentIndex());
}
}

View File

@ -67,6 +67,8 @@ private slots:
void slotWriteInputProperty(); void slotWriteInputProperty();
void slotWriteBinaryResultAsInputProperty(); void slotWriteBinaryResultAsInputProperty();
void slotCloseCase();
void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected); void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
signals: signals:

View File

@ -106,6 +106,11 @@ void RigReservoirCellResults::minMaxCellScalarValues(size_t scalarResultIndex, s
size_t i; size_t i;
for (i = 0; i < values.size(); i++) for (i = 0; i < values.size(); i++)
{ {
if (values[i] == HUGE_VAL)
{
continue;
}
if (values[i] < min) if (values[i] < min)
{ {
min = values[i]; min = values[i];
@ -172,6 +177,42 @@ void RigReservoirCellResults::p10p90CellScalarValues(size_t scalarResultIndex, d
p90 = m_p10p90[scalarResultIndex].second; p90 = m_p10p90[scalarResultIndex].second;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::meanCellScalarValues(size_t scalarResultIndex, double& meanValue)
{
CVF_ASSERT(scalarResultIndex < resultCount());
// Extend array and cache vars
if (scalarResultIndex >= m_meanValues.size() )
{
m_meanValues.resize(scalarResultIndex+1, HUGE_VAL);
}
if (m_meanValues[scalarResultIndex] != HUGE_VAL)
{
meanValue = m_meanValues[scalarResultIndex];
return;
}
double valueSum = 0.0;
size_t count = 0;
for (size_t tIdx = 0; tIdx < timeStepCount(scalarResultIndex); tIdx++)
{
std::vector<double>& values = m_cellScalarResults[scalarResultIndex][tIdx];
for (size_t cIdx = 0; cIdx < values.size(); ++cIdx)
{
valueSum += values[cIdx];
}
count += values.size();
}
m_meanValues[scalarResultIndex] = valueSum/count;
meanValue = m_meanValues[scalarResultIndex];
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -335,40 +376,190 @@ size_t RigReservoirCellResults::findScalarResultIndex(const QString& resultName)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::loadOrComputeSOIL() void RigReservoirCellResults::loadOrComputeSOIL()
{ {
size_t resultGridIndex = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); size_t soilResultGridIndex = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL");
if (resultGridIndex == cvf::UNDEFINED_SIZE_T) 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"); size_t scalarIndexSWAT = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SWAT");
size_t scalarIndexSGAS = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SGAS"); if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T)
if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T && scalarIndexSWAT != cvf::UNDEFINED_SIZE_T)
{ {
size_t timeStepCount = m_resultInfos[scalarIndexSWAT].m_timeStepDates.size(); swat = &(cellScalarResults(scalarIndexSWAT));
resultGridIndex = addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); }
m_cellScalarResults[resultGridIndex].resize(timeStepCount);
const std::vector< std::vector<double> >& sgas = cellScalarResults(scalarIndexSGAS); size_t scalarIndexSGAS = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SGAS");
const std::vector< std::vector<double> >& swat = cellScalarResults(scalarIndexSWAT); if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T)
std::vector< std::vector<double> >& soil = cellScalarResults(resultGridIndex); {
sgas = &(cellScalarResults(scalarIndexSGAS));
}
size_t resultValueCount = sgas[0].size(); // Early exit if none of SWAT or SGAS is present
if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T)
{
return;
}
size_t soilResultValueCount = 0;
size_t soilTimeStepCount = 0;
if (swat)
{
soilResultValueCount = swat->at(0).size();
soilTimeStepCount = m_resultInfos[scalarIndexSWAT].m_timeStepDates.size();
}
if (sgas)
{
soilResultValueCount = qMax(soilResultValueCount, sgas->at(0).size());
size_t sgasTimeStepCount = m_resultInfos[scalarIndexSGAS].m_timeStepDates.size();
soilTimeStepCount = qMax(soilTimeStepCount, sgasTimeStepCount);
}
soilResultGridIndex = addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL");
m_cellScalarResults[soilResultGridIndex].resize(soilTimeStepCount);
std::vector< std::vector<double> >& soil = cellScalarResults(soilResultGridIndex);
int timeStepIdx = 0; int timeStepIdx = 0;
for (timeStepIdx = 0; timeStepIdx < static_cast<int>(timeStepCount); timeStepIdx++) for (timeStepIdx = 0; timeStepIdx < static_cast<int>(soilTimeStepCount); timeStepIdx++)
{ {
soil[timeStepIdx].resize(resultValueCount); soil[timeStepIdx].resize(soilResultValueCount);
int idx = 0; int idx = 0;
#pragma omp parallel for #pragma omp parallel for
for (idx = 0; idx < static_cast<int>(resultValueCount); idx++) for (idx = 0; idx < static_cast<int>(soilResultValueCount); idx++)
{ {
soil[timeStepIdx][idx] = 1.0 - sgas[timeStepIdx][idx] - swat[timeStepIdx][idx]; double soilValue = 1.0;
if (sgas)
{
soilValue -= sgas->at(timeStepIdx)[idx];
}
if (swat)
{
soilValue -= swat->at(timeStepIdx)[idx];
}
soil[timeStepIdx][idx] = soilValue;
} }
} }
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::computeDepthRelatedResults()
{
size_t depthResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DEPTH");
size_t dxResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DX");
size_t dyResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DY");
size_t dzResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DZ");
size_t topsResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "TOPS");
size_t bottomResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM");
bool computeDepth = false;
bool computeDx = false;
bool computeDy = false;
bool computeDz = false;
bool computeTops = false;
bool computeBottom = false;
size_t resultValueCount = m_ownerMainGrid->cells().size();
if (depthResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
depthResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DEPTH", resultValueCount);
computeDepth = true;
} }
if (dxResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
dxResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DX", resultValueCount);
computeDx = true;
}
if (dyResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
dyResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DY", resultValueCount);
computeDy = true;
}
if (dzResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
dzResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DZ", resultValueCount);
computeDz = true;
}
if (topsResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
topsResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "TOPS", resultValueCount);
computeTops = true;
}
if (bottomResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
bottomResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM", resultValueCount);
computeBottom = true;
}
std::vector< std::vector<double> >& depth = cellScalarResults(depthResultGridIndex);
std::vector< std::vector<double> >& dx = cellScalarResults(dxResultGridIndex);
std::vector< std::vector<double> >& dy = cellScalarResults(dyResultGridIndex);
std::vector< std::vector<double> >& dz = cellScalarResults(dzResultGridIndex);
std::vector< std::vector<double> >& tops = cellScalarResults(topsResultGridIndex);
std::vector< std::vector<double> >& bottom = cellScalarResults(bottomResultGridIndex);
bool computeValuesForActiveCellsOnly = m_ownerMainGrid->numActiveCells() > 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())
{
continue;
}
if (computeDepth)
{
depth[0][cellIdx] = cvf::Math::abs(cell.center().z());
}
if (computeDx)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_I) - cell.faceCenter(cvf::StructGridInterface::POS_I);
dx[0][cellIdx] = cellWidth.length();
}
if (computeDy)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_J) - cell.faceCenter(cvf::StructGridInterface::POS_J);
dy[0][cellIdx] = cellWidth.length();
}
if (computeDz)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_K) - cell.faceCenter(cvf::StructGridInterface::POS_K);
dz[0][cellIdx] = cellWidth.length();
}
if (computeTops)
{
tops[0][cellIdx] = cvf::Math::abs(cell.faceCenter(cvf::StructGridInterface::NEG_K).z());
}
if (computeBottom)
{
bottom[0][cellIdx] = cvf::Math::abs(cell.faceCenter(cvf::StructGridInterface::POS_K).z());
}
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -558,3 +749,17 @@ void RigReservoirCellResults::clearAllResults()
m_cellScalarResults[i].clear(); m_cellScalarResults[i].clear();
} }
} }
//--------------------------------------------------------------------------------------------------
/// Add a result with given type and name, and allocate one result vector for the static result values
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, size_t resultValueCount)
{
size_t resultIdx = addEmptyScalarResult(type, resultName);
m_cellScalarResults[resultIdx].push_back(std::vector<double>());
m_cellScalarResults[resultIdx][0].resize(resultValueCount, HUGE_VAL);
return resultIdx;
}

View File

@ -42,6 +42,7 @@ public:
void minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max); void minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max);
const std::vector<size_t>& cellScalarValuesHistogram(size_t scalarResultIndex); const std::vector<size_t>& cellScalarValuesHistogram(size_t scalarResultIndex);
void p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90); void p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90);
void meanCellScalarValues(size_t scalarResultIndex, double& meanValue);
// Access meta-information about the results // Access meta-information about the results
size_t resultCount() const; size_t resultCount() const;
@ -66,16 +67,21 @@ public:
void clearAllResults(); void clearAllResults();
void loadOrComputeSOIL(); void loadOrComputeSOIL();
void computeDepthRelatedResults();
// Access the results data // Access the results data
std::vector< std::vector<double> > & cellScalarResults(size_t scalarResultIndex); std::vector< std::vector<double> > & cellScalarResults(size_t scalarResultIndex);
double cellScalarResult(size_t timeStepIndex, size_t scalarResultIndex, size_t resultValueIndex); double cellScalarResult(size_t timeStepIndex, size_t scalarResultIndex, size_t resultValueIndex);
private:
size_t addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, size_t resultValueCount);
private: private:
std::vector< std::vector< std::vector<double> > > m_cellScalarResults; ///< Scalar results for each timestep for each Result index (ResultVariable) std::vector< std::vector< std::vector<double> > > m_cellScalarResults; ///< Scalar results for each timestep for each Result index (ResultVariable)
std::vector< std::pair<double, double> > m_maxMinValues; ///< Max min values for each Result index std::vector< std::pair<double, double> > m_maxMinValues; ///< Max min values for each Result index
std::vector< std::vector<size_t> > m_histograms; ///< Histogram for each Result Index std::vector< std::vector<size_t> > m_histograms; ///< Histogram for each Result Index
std::vector< std::pair<double, double> > m_p10p90; ///< P10 and p90 values for each Result Index std::vector< std::pair<double, double> > m_p10p90; ///< P10 and p90 values for each Result Index
std::vector< double > m_meanValues; ///< Mean value for each Result Index
std::vector< std::vector< std::pair<double, double> > > m_maxMinValuesPrTs; ///< Max min values for each timestep and Result index std::vector< std::vector< std::pair<double, double> > > m_maxMinValuesPrTs; ///< Max min values for each timestep and Result index
@ -125,6 +131,11 @@ public:
CVF_ASSERT(m_histogram); CVF_ASSERT(m_histogram);
for (size_t i = 0; i < data.size(); ++i) for (size_t i = 0; i < data.size(); ++i)
{ {
if (data[i] == HUGE_VAL)
{
continue;
}
size_t index = 0; size_t index = 0;
if (maxIndex > 0) index = (size_t)(maxIndex*(data[i] - m_min)/m_range); if (maxIndex > 0) index = (size_t)(maxIndex*(data[i] - m_min)/m_range);

View File

@ -29,7 +29,6 @@
#include "RimReservoir.h" #include "RimReservoir.h"
#include "RigReservoir.h" #include "RigReservoir.h"
#include "RigReservoirCellResults.h" #include "RigReservoirCellResults.h"
#include <QDebug>
#include "RimInputProperty.h" #include "RimInputProperty.h"
#include "RimInputReservoir.h" #include "RimInputReservoir.h"
#include "RimUiTreeModelPdm.h" #include "RimUiTreeModelPdm.h"
@ -46,7 +45,8 @@ RiaSocketServer::RiaSocketServer(QObject* parent)
m_currentTimeStepToRead(0), m_currentTimeStepToRead(0),
m_currentReservoir(NULL), m_currentReservoir(NULL),
m_currentScalarIndex(cvf::UNDEFINED_SIZE_T), m_currentScalarIndex(cvf::UNDEFINED_SIZE_T),
m_invalidActiveCellCountDetected(false) m_invalidActiveCellCountDetected(false),
m_readState(ReadingCommand)
{ {
m_errorMessageDialog = new QErrorMessage(RIMainWindow::instance()); m_errorMessageDialog = new QErrorMessage(RIMainWindow::instance());
@ -67,7 +67,7 @@ RiaSocketServer::RiaSocketServer(QObject* parent)
return; return;
} }
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(onNewClientConnection())); connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(slotNewClientConnection()));
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -90,16 +90,31 @@ unsigned short RiaSocketServer::serverPort()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiaSocketServer::onNewClientConnection() void RiaSocketServer::slotNewClientConnection()
{ {
// If we are currently handling a connection, just ignore the new one until the queue is empty. // If we are currently handling a connection, just ignore the new one until the queue is empty.
if (m_currentClient != NULL) return; if (m_currentClient != NULL)
{
if (m_currentClient->state() == QAbstractSocket::ConnectedState)
{
return;
}
else
{
if (m_readState == ReadingPropertyData)
{
readPropertyDataFromOctave();
}
terminateCurrentConnection();
}
}
// Get the first pending connection, and set it as the current Client to handle // Get the first pending connection, and set it as the current Client to handle
QTcpSocket *newClient = m_tcpServer->nextPendingConnection(); QTcpSocket *newClient = m_tcpServer->nextPendingConnection();
this->handleClientConnection(newClient); this->handleClientConnection(newClient);
} }
@ -124,13 +139,14 @@ void RiaSocketServer::handleClientConnection(QTcpSocket* clientToHandle)
m_currentPropertyName = ""; m_currentPropertyName = "";
connect(m_currentClient, SIGNAL(disconnected()), this, SLOT(slotCurrentClientDisconnected())); connect(m_currentClient, SIGNAL(disconnected()), this, SLOT(slotCurrentClientDisconnected()));
m_readState = ReadingCommand;
if (m_currentClient->bytesAvailable()) if (m_currentClient->bytesAvailable())
{ {
this->slotReadCommand(); this->readCommandFromOctave();
} }
connect(m_currentClient, SIGNAL(readyRead()), this, SLOT(slotReadCommand())); connect(m_currentClient, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -178,7 +194,7 @@ RimReservoir* RiaSocketServer::findReservoir(const QString& caseName)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiaSocketServer::slotReadCommand() void RiaSocketServer::readCommandFromOctave()
{ {
QDataStream socketStream(m_currentClient); QDataStream socketStream(m_currentClient);
socketStream.setVersion(QDataStream::Qt_4_0); socketStream.setVersion(QDataStream::Qt_4_0);
@ -210,16 +226,17 @@ void RiaSocketServer::slotReadCommand()
CVF_ASSERT(args.size() > 0); CVF_ASSERT(args.size() > 0);
// qDebug() << args;
bool isGetProperty = args[0] == "GetProperty"; // GetProperty [casename/index] PropertyName bool isGetProperty = args[0] == "GetProperty"; // GetProperty [casename/index] PropertyName
bool isSetProperty = args[0] == "SetProperty"; // SetProperty [casename/index] PropertyName bool isSetProperty = args[0] == "SetProperty"; // SetProperty [casename/index] PropertyName
bool isGetCellInfo = args[0] == "GetActiveCellInfo"; // GetActiveCellInfo [casename/index] bool isGetCellInfo = args[0] == "GetActiveCellInfo"; // GetActiveCellInfo [casename/index]
bool isGetGridDim = args[0] == "GetMainGridDimensions"; // GetMainGridDimensions [casename/index] bool isGetGridDim = args[0] == "GetMainGridDimensions"; // GetMainGridDimensions [casename/index]
if (!(isGetProperty || isSetProperty || isGetCellInfo || isGetGridDim)) if (!(isGetProperty || isSetProperty || isGetCellInfo || isGetGridDim))
{ {
m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("Unknown command: %1").arg(args[0].data())); m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("Unknown command: %1").arg(args[0].data()));
terminateCurrentConnection();
return; return;
} }
@ -307,8 +324,6 @@ void RiaSocketServer::slotReadCommand()
quint64 timestepByteCount = (quint64)(timestepResultCount*sizeof(double)); quint64 timestepByteCount = (quint64)(timestepResultCount*sizeof(double));
socketStream << timestepByteCount ; socketStream << timestepByteCount ;
// qDebug() << "Trying to read " << (quint64)(scalarResultFrames->front().size()*sizeof(double)) << "bytes of data";
// Then write the data. // Then write the data.
for (size_t tIdx = 0; tIdx < scalarResultFrames->size(); ++tIdx) for (size_t tIdx = 0; tIdx < scalarResultFrames->size(); ++tIdx)
@ -326,8 +341,9 @@ void RiaSocketServer::slotReadCommand()
} }
else // Set property else // Set property
{ {
m_readState = ReadingPropertyData;
// Disconnect the socket from calling this slot again. // Disconnect the socket from calling this slot again.
m_currentClient->disconnect(SIGNAL(readyRead()));
m_currentReservoir = reservoir; m_currentReservoir = reservoir;
if ( scalarResultFrames != NULL) if ( scalarResultFrames != NULL)
@ -335,10 +351,8 @@ void RiaSocketServer::slotReadCommand()
m_scalarResultsToAdd = scalarResultFrames; m_scalarResultsToAdd = scalarResultFrames;
if (m_currentClient->bytesAvailable()) if (m_currentClient->bytesAvailable())
{ {
this->slotReadPropertyData(); this->readPropertyDataFromOctave();
} }
connect(m_currentClient, SIGNAL(readyRead()), this, SLOT(slotReadPropertyData()));
} }
} }
} }
@ -402,7 +416,7 @@ void RiaSocketServer::slotReadCommand()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// This method reads data from octave and puts it into the resInsight Structures /// This method reads data from octave and puts it into the resInsight Structures
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiaSocketServer::slotReadPropertyData() void RiaSocketServer::readPropertyDataFromOctave()
{ {
QDataStream socketStream(m_currentClient); QDataStream socketStream(m_currentClient);
socketStream.setVersion(QDataStream::Qt_4_0); socketStream.setVersion(QDataStream::Qt_4_0);
@ -530,24 +544,10 @@ void RiaSocketServer::slotCurrentClientDisconnected()
&& m_currentClient->bytesAvailable() && m_currentClient->bytesAvailable()
&& !m_invalidActiveCellCountDetected) && !m_invalidActiveCellCountDetected)
{ {
this->slotReadPropertyData(); this->readPropertyDataFromOctave();
} }
m_currentClient->deleteLater(); terminateCurrentConnection();
m_currentClient = NULL;
// Clean up more state:
m_currentCommandSize = 0;
m_scalarResultsToAdd = NULL;
m_timeStepCountToRead = 0;
m_bytesPerTimeStepToRead = 0;
m_currentTimeStepToRead = 0;
m_currentReservoir = NULL;
m_currentScalarIndex = cvf::UNDEFINED_SIZE_T;
m_currentPropertyName = "";
m_invalidActiveCellCountDetected = false;
QTcpSocket *newClient = m_tcpServer->nextPendingConnection(); QTcpSocket *newClient = m_tcpServer->nextPendingConnection();
@ -556,3 +556,58 @@ void RiaSocketServer::slotCurrentClientDisconnected()
this->handleClientConnection(newClient); this->handleClientConnection(newClient);
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSocketServer::terminateCurrentConnection()
{
if (m_currentClient)
{
m_currentClient->disconnect(SIGNAL(disconnected()));
m_currentClient->disconnect(SIGNAL(readyRead()));
m_currentClient->deleteLater();
m_currentClient = NULL;
}
// Clean up more state:
m_currentCommandSize = 0;
m_timeStepCountToRead = 0;
m_bytesPerTimeStepToRead = 0;
m_currentTimeStepToRead = 0;
m_scalarResultsToAdd = NULL;
m_currentReservoir = NULL;
m_currentScalarIndex = cvf::UNDEFINED_SIZE_T;
m_currentPropertyName = "";
m_invalidActiveCellCountDetected = false;
m_readState = ReadingCommand;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSocketServer::slotReadyRead()
{
switch (m_readState)
{
case ReadingCommand :
{
readCommandFromOctave();
break;
}
case ReadingPropertyData :
{
readPropertyDataFromOctave();
break;
}
default:
CVF_ASSERT(false);
break;
}
}

View File

@ -19,6 +19,7 @@
#pragma once #pragma once
#include <QDialog> #include <QDialog>
#include <QAbstractSocket>
class QLabel; class QLabel;
class QPushButton; class QPushButton;
@ -28,24 +29,32 @@ class QNetworkSession;
class QErrorMessage; class QErrorMessage;
class RimReservoir; class RimReservoir;
class RiaSocketServer : public QObject class RiaSocketServer : public QObject
{ {
Q_OBJECT Q_OBJECT
public:
enum ReadState {ReadingCommand, ReadingPropertyData};
public: public:
RiaSocketServer(QObject *parent = 0); RiaSocketServer(QObject *parent = 0);
~RiaSocketServer(); ~RiaSocketServer();
unsigned short serverPort(); unsigned short serverPort();
private slots: private slots:
void onNewClientConnection(); void slotNewClientConnection();
void slotReadCommand();
void slotReadPropertyData();
void slotCurrentClientDisconnected(); void slotCurrentClientDisconnected();
void slotReadyRead();
private: private:
void readCommandFromOctave();
void readPropertyDataFromOctave();
void handleClientConnection( QTcpSocket* clientToHandle); void handleClientConnection( QTcpSocket* clientToHandle);
RimReservoir* findReservoir(const QString &casename); RimReservoir* findReservoir(const QString &casename);
void terminateCurrentConnection();
private: private:
QTcpServer* m_tcpServer; QTcpServer* m_tcpServer;
@ -56,6 +65,7 @@ private:
// Vars used for reading data from octave and adding them to the available results // Vars used for reading data from octave and adding them to the available results
ReadState m_readState;
quint64 m_timeStepCountToRead; quint64 m_timeStepCountToRead;
quint64 m_bytesPerTimeStepToRead; quint64 m_bytesPerTimeStepToRead;
size_t m_currentTimeStepToRead; size_t m_currentTimeStepToRead;

View File

@ -291,6 +291,8 @@ void RIMainWindow::createMenus()
viewMenu->addAction(m_viewFromEast); viewMenu->addAction(m_viewFromEast);
viewMenu->addAction(m_viewFromBelow); viewMenu->addAction(m_viewFromBelow);
viewMenu->addAction(m_viewFromAbove); viewMenu->addAction(m_viewFromAbove);
viewMenu->addSeparator();
viewMenu->addAction(m_newPropertyView);
connect(viewMenu, SIGNAL(aboutToShow()), SLOT(slotRefreshViewActions())); connect(viewMenu, SIGNAL(aboutToShow()), SLOT(slotRefreshViewActions()));
@ -300,8 +302,6 @@ void RIMainWindow::createMenus()
debugMenu->addAction(m_mockResultsModelAction); debugMenu->addAction(m_mockResultsModelAction);
debugMenu->addAction(m_mockLargeResultsModelAction); debugMenu->addAction(m_mockLargeResultsModelAction);
debugMenu->addAction(m_mockInputModelAction); debugMenu->addAction(m_mockInputModelAction);
debugMenu->addSeparator();
debugMenu->addAction(m_newPropertyView);
connect(debugMenu, SIGNAL(aboutToShow()), SLOT(slotRefreshDebugActions())); connect(debugMenu, SIGNAL(aboutToShow()), SLOT(slotRefreshDebugActions()));
@ -595,13 +595,19 @@ void RIMainWindow::slotOpenBinaryGridFiles()
{ {
if (checkForDocumentModifications()) if (checkForDocumentModifications())
{ {
RIApplication* app = RIApplication::instance();
#ifdef USE_ECL_LIB #ifdef USE_ECL_LIB
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Open Eclipse File", NULL, "Eclipse Grid Files (*.GRID *.EGRID)");
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 #else
QStringList fileNames; QStringList fileNames;
fileNames << "dummy"; fileNames << "dummy";
#endif #endif
RIApplication* app = RIApplication::instance();
int i; int i;
for (i = 0; i < fileNames.size(); i++) for (i = 0; i < fileNames.size(); i++)
@ -624,11 +630,15 @@ void RIMainWindow::slotOpenInputFiles()
{ {
if (checkForDocumentModifications()) if (checkForDocumentModifications())
{ {
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Open Eclipse Input Files", NULL, "Eclipse Input Files and Input Properties (*.GRDECL *)"); RIApplication* app = RIApplication::instance();
QString defaultDir = app->defaultFileDialogDirectory("INPUT_FILES");
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Open Eclipse Input Files", defaultDir, "Eclipse Input Files and Input Properties (*.GRDECL *)");
if (fileNames.isEmpty()) return; if (fileNames.isEmpty()) return;
RIApplication* app = RIApplication::instance(); // Remember the path to next time
app->setDefaultFileDialogDirectory("INPUT_FILES", QFileInfo(fileNames.last()).absolutePath());
app->openInputEclipseCase("Eclipse Input Files", fileNames); app->openInputEclipseCase("Eclipse Input Files", fileNames);
} }
} }
@ -641,10 +651,15 @@ void RIMainWindow::slotOpenProject()
{ {
if (checkForDocumentModifications()) if (checkForDocumentModifications())
{ {
QString fileName = QFileDialog::getOpenFileName(this, "Open ResInsight Project", NULL, "ResInsight project (*.rip)"); RIApplication* app = RIApplication::instance();
QString defaultDir = app->defaultFileDialogDirectory("BINARY_GRID");
QString fileName = QFileDialog::getOpenFileName(this, "Open ResInsight Project", defaultDir, "ResInsight project (*.rip)");
if (fileName.isEmpty()) return; if (fileName.isEmpty()) return;
RIApplication* app = RIApplication::instance(); // Remember the path to next time
app->setDefaultFileDialogDirectory("BINARY_GRID", QFileInfo(fileName).absolutePath());
app->loadProject(fileName); app->loadProject(fileName);
} }

View File

@ -96,7 +96,9 @@ RIViewer::RIViewer(const QGLFormat& format, QWidget* parent)
m_animationProgress->setPalette(p); m_animationProgress->setPalette(p);
m_animationProgress->setFormat("Time Step: %v/%m"); m_animationProgress->setFormat("Time Step: %v/%m");
m_animationProgress->setTextVisible(true); m_animationProgress->setTextVisible(true);
m_animationProgress->setStyle(new QCDEStyle());
m_progressBarStyle = new QCDEStyle();
m_animationProgress->setStyle(m_progressBarStyle);
m_showAnimProgress = false; m_showAnimProgress = false;
// Histogram // Histogram
@ -114,6 +116,11 @@ RIViewer::~RIViewer()
{ {
m_reservoirView->showWindow = false; m_reservoirView->showWindow = false;
m_reservoirView->cameraPosition = m_mainCamera->viewMatrix(); m_reservoirView->cameraPosition = m_mainCamera->viewMatrix();
delete m_InfoLabel;
delete m_animationProgress;
delete m_histogramWidget;
delete m_progressBarStyle;
} }
@ -405,6 +412,12 @@ cvf::Part* RIViewer::pickPointAndFace(int winPosX, int winPosY, uint* faceHit, c
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RIViewer::paintOverlayItems(QPainter* painter) void RIViewer::paintOverlayItems(QPainter* painter)
{ {
// No support for overlay items using SW rendering yet.
if (!isShadersSupported())
{
return;
}
int columnWidth = 200; int columnWidth = 200;
int margin = 5; int margin = 5;
int yPos = margin; int yPos = margin;
@ -471,9 +484,10 @@ void RIViewer::setHistogram(double min, double max, const std::vector<size_t>& h
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RIViewer::setHistogramPercentiles(double pmin, double pmax) void RIViewer::setHistogramPercentiles(double pmin, double pmax, double mean)
{ {
m_histogramWidget->setPercentiles(pmin, pmax); m_histogramWidget->setPercentiles(pmin, pmax);
m_histogramWidget->setMean(mean);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -29,6 +29,7 @@ class RimReservoirView;
class QLabel; class QLabel;
class QProgressBar; class QProgressBar;
class RiuSimpleHistogramWidget; class RiuSimpleHistogramWidget;
class QCDEStyle;
namespace cvf namespace cvf
{ {
@ -60,7 +61,7 @@ public:
void setInfoText(QString text); void setInfoText(QString text);
void showHistogram(bool enable); void showHistogram(bool enable);
void setHistogram(double min, double max, const std::vector<size_t>& histogram); void setHistogram(double min, double max, const std::vector<size_t>& histogram);
void setHistogramPercentiles(double pmin, double pmax); void setHistogramPercentiles(double pmin, double pmax, double mean);
void showAnimationProgress(bool enable); void showAnimationProgress(bool enable);
@ -88,6 +89,7 @@ private:
RiuSimpleHistogramWidget* m_histogramWidget; RiuSimpleHistogramWidget* m_histogramWidget;
bool m_showHistogram; bool m_showHistogram;
QCDEStyle* m_progressBarStyle;
cvf::ref<cvf::OverlayScalarMapperLegend> m_legend1; cvf::ref<cvf::OverlayScalarMapperLegend> m_legend1;

View File

@ -10,6 +10,8 @@ QWidget(parent, f)
{ {
m_minPercentile = HUGE_VAL; m_minPercentile = HUGE_VAL;
m_maxPercentile = HUGE_VAL; m_maxPercentile = HUGE_VAL;
m_mean = HUGE_VAL;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -78,6 +80,14 @@ void RiuSimpleHistogramWidget::draw(QPainter *painter,int x, int y, int width, i
painter->setPen(QColor(255, 0, 0, 200)); painter->setPen(QColor(255, 0, 0, 200));
painter->drawLine(xpos, y+1, xpos, y + height -1); painter->drawLine(xpos, y+1, xpos, y + height -1);
} }
// Vertical lines for percentiles
if (m_mean != HUGE_VAL)
{
int xpos = xPosFromDomainValue(m_mean);
painter->setPen(QColor(0, 0, 255, 200));
painter->drawLine(xpos, y+1, xpos, y + height -1);
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -11,6 +11,7 @@ public:
void setHistogramData(double min, double max, const std::vector<size_t>& histogram); void setHistogramData(double min, double max, const std::vector<size_t>& histogram);
void setPercentiles(double pmin, double pmax) {m_minPercentile = pmin; m_maxPercentile = pmax;} void setPercentiles(double pmin, double pmax) {m_minPercentile = pmin; m_maxPercentile = pmax;}
void setMean(double mean) {m_mean = mean;}
protected: protected:
virtual void paintEvent(QPaintEvent* event); virtual void paintEvent(QPaintEvent* event);
@ -28,6 +29,7 @@ private:
double m_min; double m_min;
double m_minPercentile; double m_minPercentile;
double m_maxPercentile; double m_maxPercentile;
double m_mean;
size_t m_maxHistogramCount; size_t m_maxHistogramCount;
double m_width; double m_width;

View File

@ -33,8 +33,8 @@ ENDIF()
################################################################################ ################################################################################
set(CMAKE_MAJOR_VERSION 0) set(CMAKE_MAJOR_VERSION 0)
set(CMAKE_MINOR_VERSION 8) set(CMAKE_MINOR_VERSION 9)
set(CMAKE_PATCH_VERSION 7) set(CMAKE_PATCH_VERSION 0)
set(PRODUCTVER ${CMAKE_MAJOR_VERSION},${CMAKE_MINOR_VERSION},0,${CMAKE_PATCH_VERSION}) set(PRODUCTVER ${CMAKE_MAJOR_VERSION},${CMAKE_MINOR_VERSION},0,${CMAKE_PATCH_VERSION})
set(STRPRODUCTVER ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}) set(STRPRODUCTVER ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION})

View File

@ -92,7 +92,7 @@ extern "C" {
buffer_type * buffer_fread_alloc(const char * filename); buffer_type * buffer_fread_alloc(const char * filename);
void buffer_fread_realloc(buffer_type * buffer , const char * filename); void buffer_fread_realloc(buffer_type * buffer , const char * filename);
#ifdef HAVE_ZLIB #ifdef WITH_ZLIB
size_t buffer_fwrite_compressed(buffer_type * buffer, const void * ptr , size_t byte_size); 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); size_t buffer_fread_compressed(buffer_type * buffer , size_t compressed_size , void * target_ptr , size_t target_size);
#endif #endif

View File

@ -61,11 +61,15 @@ extern "C" {
bool ecl_grid_ijk_valid(const ecl_grid_type * , int , int , int ); bool ecl_grid_ijk_valid(const ecl_grid_type * , int , int , int );
int ecl_grid_get_global_index3(const ecl_grid_type * , int , int , int ); int ecl_grid_get_global_index3(const ecl_grid_type * , int , int , int );
int ecl_grid_get_global_index1A(const ecl_grid_type * ecl_grid , int active_index); int ecl_grid_get_global_index1A(const ecl_grid_type * ecl_grid , int active_index);
ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw ); ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw );
ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , const float * mapaxes); ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , const float * mapaxes);
ecl_grid_type * ecl_grid_alloc_GRID_data(int num_coords , int nx, int ny , int nz , int coords_size , int ** coords , float ** corners , const float * mapaxes); ecl_grid_type * ecl_grid_alloc_GRID_data(int num_coords , int nx, int ny , int nz , int coords_size , int ** coords , float ** corners , const float * mapaxes);
ecl_grid_type * ecl_grid_alloc(const char * ); ecl_grid_type * ecl_grid_alloc(const char * );
ecl_grid_type * ecl_grid_load_case( const char * case_input ); ecl_grid_type * ecl_grid_load_case( const char * case_input );
ecl_grid_type * ecl_grid_alloc_rectangular( int nx , int ny , int nz , double dx , double dy , double dz , const int * actnum);
ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum);
bool ecl_grid_exists( const char * case_input ); bool ecl_grid_exists( const char * case_input );
char * ecl_grid_alloc_case_filename( const char * case_input ); char * ecl_grid_alloc_case_filename( const char * case_input );
@ -148,6 +152,9 @@ extern "C" {
ecl_kw_type * ecl_grid_alloc_hostnum_kw( const ecl_grid_type * grid ); ecl_kw_type * ecl_grid_alloc_hostnum_kw( const ecl_grid_type * grid );
ecl_kw_type * ecl_grid_alloc_gridhead_kw( int nx, int ny , int nz , int grid_nr); ecl_kw_type * ecl_grid_alloc_gridhead_kw( int nx, int ny , int nz , int grid_nr);
void ecl_grid_ri_export( const ecl_grid_type * ecl_grid , double * ri_points);
void ecl_grid_cell_ri_export( const ecl_grid_type * ecl_grid , int global_index , double * ri_points);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -103,9 +103,6 @@ extern "C" {
bool ecl_kw_is_grdecl_file(FILE * ); bool ecl_kw_is_grdecl_file(FILE * );
bool ecl_kw_is_kw_file(FILE * , bool ); bool ecl_kw_is_kw_file(FILE * , bool );
void ecl_kw_inplace_sub(ecl_kw_type * , const ecl_kw_type * );
void ecl_kw_inplace_mul(ecl_kw_type * , const ecl_kw_type * );
void ecl_kw_inplace_div(ecl_kw_type * , const ecl_kw_type * );
double ecl_kw_element_sum_float( const ecl_kw_type * ecl_kw ); 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_inplace_inv(ecl_kw_type * my_kw);
@ -113,8 +110,6 @@ extern "C" {
void ecl_kw_max_min(const ecl_kw_type * , void * , void *); void ecl_kw_max_min(const ecl_kw_type * , void * , void *);
void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw); void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw);
double ecl_kw_iget_as_double(const ecl_kw_type * , int );
ecl_kw_type * ecl_kw_buffer_alloc(buffer_type * buffer); 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_buffer_store(const ecl_kw_type * ecl_kw , buffer_type * buffer);
@ -149,29 +144,29 @@ extern "C" {
void ecl_kw_copy_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * src_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); 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); #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( int );
ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float ) ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float );
ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double ) ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double );
#undef ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER #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); #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( int );
ECL_KW_SCALE_TYPED_HEADER( float ) ECL_KW_SCALE_TYPED_HEADER( float );
ECL_KW_SCALE_TYPED_HEADER( double ) ECL_KW_SCALE_TYPED_HEADER( double );
#undef ECL_KW_SCALE_TYPED_HEADER #undef ECL_KW_SCALE_TYPED_HEADER
void ecl_kw_scale_float_or_double( ecl_kw_type * ecl_kw , double scale_factor ); 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); #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( int );
ECL_KW_SHIFT_TYPED_HEADER( float ) ECL_KW_SHIFT_TYPED_HEADER( float );
ECL_KW_SHIFT_TYPED_HEADER( double ) ECL_KW_SHIFT_TYPED_HEADER( double );
#undef ECL_KW_SHIFT_TYPED_HEADER #undef ECL_KW_SHIFT_TYPED_HEADER
void ecl_kw_shift_float_or_double( ecl_kw_type * ecl_kw , double shift_value ); 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); #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(double);
ECL_KW_IGET_TYPED_HEADER(float); ECL_KW_IGET_TYPED_HEADER(float);
ECL_KW_IGET_TYPED_HEADER(int); ECL_KW_IGET_TYPED_HEADER(int);
@ -179,7 +174,7 @@ extern "C" {
bool ecl_kw_iget_bool( const ecl_kw_type * ecl_kw , int i ); 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 ); #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(double);
ECL_KW_ISET_TYPED_HEADER(float); ECL_KW_ISET_TYPED_HEADER(float);
ECL_KW_ISET_TYPED_HEADER(int); ECL_KW_ISET_TYPED_HEADER(int);
@ -187,7 +182,7 @@ extern "C" {
void ecl_kw_iset_bool( ecl_kw_type * ecl_kw , int i , bool bool_value); 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 *); #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(double);
ECL_KW_GET_TYPED_PTR_HEADER(float); ECL_KW_GET_TYPED_PTR_HEADER(float);
ECL_KW_GET_TYPED_PTR_HEADER(int); ECL_KW_GET_TYPED_PTR_HEADER(int);
@ -195,31 +190,31 @@ extern "C" {
#undef ECL_KW_GET_TYPED_PTR_HEADER #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); #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( double );
ECL_KW_SET_INDEXED_HEADER( float ); ECL_KW_SET_INDEXED_HEADER( float );
ECL_KW_SET_INDEXED_HEADER( int ); ECL_KW_SET_INDEXED_HEADER( int );
#undef ECL_KW_SET_INDEXED_HEADER #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); #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( int );
ECL_KW_SHIFT_INDEXED_HEADER( float ) ECL_KW_SHIFT_INDEXED_HEADER( float );
ECL_KW_SHIFT_INDEXED_HEADER( double ) ECL_KW_SHIFT_INDEXED_HEADER( double );
#undef ECL_KW_SHIFT_INDEXED_HEADER #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); #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( int );
ECL_KW_SCALE_INDEXED_HEADER( float ) ECL_KW_SCALE_INDEXED_HEADER( float );
ECL_KW_SCALE_INDEXED_HEADER( double ) ECL_KW_SCALE_INDEXED_HEADER( double );
#undef ECL_KW_SCALE_INDEXED_HEADER #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); #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( int );
ECL_KW_MAX_MIN_HEADER( float ) ECL_KW_MAX_MIN_HEADER( float );
ECL_KW_MAX_MIN_HEADER( double ) ECL_KW_MAX_MIN_HEADER( double );
#undef ECL_KW_MAX_MIN_HEADER #undef ECL_KW_MAX_MIN_HEADER
#include <ecl_kw_grdecl.h> #include <ecl_kw_grdecl.h>

View File

@ -255,6 +255,9 @@ extern "C" {
/* Common keywords */ /* Common keywords */
#define SPECGRID_KW "SPECGRID" #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 #define MAPAXES_KW "MAPAXES" /* Keyword used to transform from grid coordinates to
world coordinates. */ world coordinates. */
#define LGR_KW "LGR" /* Name of LGR; for GRID files it can contain two elements, #define LGR_KW "LGR" /* Name of LGR; for GRID files it can contain two elements,

View File

@ -44,7 +44,8 @@ typedef struct ecl_smspec_struct ecl_smspec_type;
ecl_smspec_install_gen_key() must be updated. ecl_smspec_install_gen_key() must be updated.
*/ */
const int_vector_type * ecl_smspec_get_index_map( const ecl_smspec_type * smspec ); 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 ); 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 ); 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_num( ecl_smspec_var_type var_type );
@ -112,7 +113,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type;
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); 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); stringlist_type * ecl_smspec_alloc_matching_general_var_list(const ecl_smspec_type * smspec , const char * pattern);

View File

@ -173,6 +173,8 @@ typedef struct ecl_sum_struct ecl_sum_type;
void ecl_sum_fwrite( const ecl_sum_type * ecl_sum ); void ecl_sum_fwrite( const ecl_sum_type * ecl_sum );
void ecl_sum_fwrite_smspec( const ecl_sum_type * ecl_sum ); void ecl_sum_fwrite_smspec( const ecl_sum_type * ecl_sum );
smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , int num , const char * unit , float default_value); smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , int num , const char * unit , float default_value);
smspec_node_type * ecl_sum_add_blank_var( ecl_sum_type * ecl_sum , float default_value);
void ecl_sum_init_var( ecl_sum_type * ecl_sum , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num , const char * unit);
ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_days); ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_days);
void ecl_sum_update_wgname( ecl_sum_type * ecl_sum , smspec_node_type * node , const char * wgname ); void ecl_sum_update_wgname( ecl_sum_type * ecl_sum , smspec_node_type * node , const char * wgname );

View File

@ -131,6 +131,7 @@ typedef struct matrix_struct matrix_type;
double matrix_trace(const matrix_type *matrix); double matrix_trace(const matrix_type *matrix);
double matrix_diag_std(const matrix_type * Sk,double mean); double matrix_diag_std(const matrix_type * Sk,double mean);
double matrix_det3( const matrix_type * A); double matrix_det3( const matrix_type * A);
double matrix_det4( const matrix_type * A);
#ifdef HAVE_ISFINITE #ifdef HAVE_ISFINITE
bool matrix_is_finite(const matrix_type * matrix); bool matrix_is_finite(const matrix_type * matrix);

View File

@ -27,8 +27,6 @@ extern "C" {
typedef struct path_fmt_struct path_fmt_type; typedef struct path_fmt_struct path_fmt_type;
path_fmt_type * path_fmt_safe_cast(const void * arg);
path_fmt_type * path_fmt_alloc_directory_fmt(const char * ); path_fmt_type * path_fmt_alloc_directory_fmt(const char * );
path_fmt_type * path_fmt_alloc_path_fmt(const char * ); path_fmt_type * path_fmt_alloc_path_fmt(const char * );
path_fmt_type * path_fmt_copyc(const path_fmt_type *); path_fmt_type * path_fmt_copyc(const path_fmt_type *);
@ -36,6 +34,7 @@ path_fmt_type * path_fmt_scanf_alloc(const char * , int , const node_ctype * ,
char * path_fmt_alloc_path(const path_fmt_type * , bool , ...); char * path_fmt_alloc_path(const path_fmt_type * , bool , ...);
char * path_fmt_alloc_file(const path_fmt_type * , bool , ...); char * path_fmt_alloc_file(const path_fmt_type * , bool , ...);
void path_fmt_free(path_fmt_type * ); void path_fmt_free(path_fmt_type * );
void path_fmt_free__( void * arg );
const char * path_fmt_get_fmt(const path_fmt_type * ); const char * path_fmt_get_fmt(const path_fmt_type * );
void path_fmt_reset_fmt(path_fmt_type * , const char * ); void path_fmt_reset_fmt(path_fmt_type * , const char * );
void path_fmt_make_path(const path_fmt_type * ); void path_fmt_make_path(const path_fmt_type * );

View File

@ -68,6 +68,15 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
char * smspec_alloc_local_completion_key( const char * join_string, const char * keyword , const char * lgr_name , const char * wgname , int i , int j , int k); char * smspec_alloc_local_completion_key( const char * join_string, const char * keyword , const char * lgr_name , const char * wgname , int i , int j , int k);
bool smspec_node_init( smspec_node_type * smspec_node,
ecl_smspec_var_type var_type ,
const char * wgname ,
const char * keyword ,
const char * unit ,
const char * key_join_string ,
const int grid_dims[3] ,
int num);
smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type , smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type ,
const char * wgname , const char * wgname ,
@ -87,6 +96,7 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
int param_index, int param_index,
float default_value); float default_value);
smspec_node_type * smspec_node_alloc_new(int params_index, float default_value);
void smspec_node_free( smspec_node_type * index ); void smspec_node_free( smspec_node_type * index );
void smspec_node_free__(void * arg); void smspec_node_free__(void * arg);
@ -100,12 +110,16 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
void smspec_node_update_wgname( smspec_node_type * index , const char * wgname , const char * key_join_string); void smspec_node_update_wgname( smspec_node_type * index , const char * wgname , const char * key_join_string);
const char * smspec_node_get_keyword( const smspec_node_type * smspec_node); const char * smspec_node_get_keyword( const smspec_node_type * smspec_node);
const char * smspec_node_get_unit( const smspec_node_type * smspec_node); const char * smspec_node_get_unit( const smspec_node_type * smspec_node);
void smspec_node_set_unit( smspec_node_type * smspec_node , const char * unit );
bool smspec_node_is_rate( const smspec_node_type * smspec_node ); bool smspec_node_is_rate( const smspec_node_type * smspec_node );
bool smspec_node_is_total( const smspec_node_type * smspec_node ); bool smspec_node_is_total( const smspec_node_type * smspec_node );
bool smspec_node_need_nums( const smspec_node_type * smspec_node ); bool smspec_node_need_nums( const smspec_node_type * smspec_node );
float smspec_node_get_default_value( const smspec_node_type * smspec_node );
void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream); void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream);
void smspec_node_set_default( smspec_node_type * smspec_node , float default_value);
float smspec_node_get_default( const smspec_node_type * smspec_node);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -18,8 +18,8 @@
#ifndef __THREAD_POOL_H__ #ifndef __THREAD_POOL_H__
#define __THREAD_POOL_H__ #define __THREAD_POOL_H__
#ifdef HAVE_PTHREAD #ifdef WITH_PTHREAD
#define HAVE_THREAD_POOL #define WITH_THREAD_POOL
#include "thread_pool_posix.h" #include "thread_pool_posix.h"
#endif #endif

View File

@ -405,7 +405,7 @@ const char * util_enum_iget( int index , int size , const util_enum_element_type
/*****************************************************************/ /*****************************************************************/
/* Conditional section below here */ /* Conditional section below here */
#ifdef HAVE_ZLIB #ifdef WITH_ZLIB
void util_compress_buffer(const void * , int , void * , unsigned long * ); void util_compress_buffer(const void * , int , void * , unsigned long * );
int util_fread_sizeof_compressed(FILE * stream); int util_fread_sizeof_compressed(FILE * stream);
void util_fread_compressed(void * , FILE * ); void util_fread_compressed(void * , FILE * );

View File

@ -23,6 +23,7 @@
extern "C" { extern "C" {
#endif #endif
#include <node_data.h> #include <node_data.h>
#include <type_macros.h>
typedef void ( vector_func_type ) (void * , void *); typedef void ( vector_func_type ) (void * , void *);
typedef int ( vector_cmp_ftype) (const void * , const void *); typedef int ( vector_cmp_ftype) (const void * , const void *);
@ -30,8 +31,8 @@ typedef int ( vector_cmp_ftype) (const void * , const void *);
typedef struct vector_struct vector_type; typedef struct vector_struct vector_type;
vector_type * vector_alloc_new(); vector_type * vector_alloc_new();
void vector_grow_NULL( vector_type * vector , int new_size );
vector_type * vector_alloc_NULL_initialized( int size ); vector_type * vector_alloc_NULL_initialized( int size );
int vector_append_ref( vector_type * , const void *); int vector_append_ref( vector_type * , const void *);
@ -77,6 +78,7 @@ vector_type * vector_alloc_copy(const vector_type * src , bool deep_copy);
void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size);
UTIL_IS_INSTANCE_HEADER( vector );
#ifdef __cplusplus #ifdef __cplusplus
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -92,7 +92,7 @@ extern "C" {
buffer_type * buffer_fread_alloc(const char * filename); buffer_type * buffer_fread_alloc(const char * filename);
void buffer_fread_realloc(buffer_type * buffer , const char * filename); void buffer_fread_realloc(buffer_type * buffer , const char * filename);
#ifdef HAVE_ZLIB #ifdef WITH_ZLIB
size_t buffer_fwrite_compressed(buffer_type * buffer, const void * ptr , size_t byte_size); 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); size_t buffer_fread_compressed(buffer_type * buffer , size_t compressed_size , void * target_ptr , size_t target_size);
#endif #endif

View File

@ -61,11 +61,15 @@ extern "C" {
bool ecl_grid_ijk_valid(const ecl_grid_type * , int , int , int ); bool ecl_grid_ijk_valid(const ecl_grid_type * , int , int , int );
int ecl_grid_get_global_index3(const ecl_grid_type * , int , int , int ); int ecl_grid_get_global_index3(const ecl_grid_type * , int , int , int );
int ecl_grid_get_global_index1A(const ecl_grid_type * ecl_grid , int active_index); int ecl_grid_get_global_index1A(const ecl_grid_type * ecl_grid , int active_index);
ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw ); ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw );
ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , const float * mapaxes); ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , const float * mapaxes);
ecl_grid_type * ecl_grid_alloc_GRID_data(int num_coords , int nx, int ny , int nz , int coords_size , int ** coords , float ** corners , const float * mapaxes); ecl_grid_type * ecl_grid_alloc_GRID_data(int num_coords , int nx, int ny , int nz , int coords_size , int ** coords , float ** corners , const float * mapaxes);
ecl_grid_type * ecl_grid_alloc(const char * ); ecl_grid_type * ecl_grid_alloc(const char * );
ecl_grid_type * ecl_grid_load_case( const char * case_input ); ecl_grid_type * ecl_grid_load_case( const char * case_input );
ecl_grid_type * ecl_grid_alloc_rectangular( int nx , int ny , int nz , double dx , double dy , double dz , const int * actnum);
ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum);
bool ecl_grid_exists( const char * case_input ); bool ecl_grid_exists( const char * case_input );
char * ecl_grid_alloc_case_filename( const char * case_input ); char * ecl_grid_alloc_case_filename( const char * case_input );
@ -148,6 +152,9 @@ extern "C" {
ecl_kw_type * ecl_grid_alloc_hostnum_kw( const ecl_grid_type * grid ); ecl_kw_type * ecl_grid_alloc_hostnum_kw( const ecl_grid_type * grid );
ecl_kw_type * ecl_grid_alloc_gridhead_kw( int nx, int ny , int nz , int grid_nr); ecl_kw_type * ecl_grid_alloc_gridhead_kw( int nx, int ny , int nz , int grid_nr);
void ecl_grid_ri_export( const ecl_grid_type * ecl_grid , double * ri_points);
void ecl_grid_cell_ri_export( const ecl_grid_type * ecl_grid , int global_index , double * ri_points);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -103,9 +103,6 @@ extern "C" {
bool ecl_kw_is_grdecl_file(FILE * ); bool ecl_kw_is_grdecl_file(FILE * );
bool ecl_kw_is_kw_file(FILE * , bool ); bool ecl_kw_is_kw_file(FILE * , bool );
void ecl_kw_inplace_sub(ecl_kw_type * , const ecl_kw_type * );
void ecl_kw_inplace_mul(ecl_kw_type * , const ecl_kw_type * );
void ecl_kw_inplace_div(ecl_kw_type * , const ecl_kw_type * );
double ecl_kw_element_sum_float( const ecl_kw_type * ecl_kw ); 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_inplace_inv(ecl_kw_type * my_kw);
@ -113,8 +110,6 @@ extern "C" {
void ecl_kw_max_min(const ecl_kw_type * , void * , void *); void ecl_kw_max_min(const ecl_kw_type * , void * , void *);
void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw); void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw);
double ecl_kw_iget_as_double(const ecl_kw_type * , int );
ecl_kw_type * ecl_kw_buffer_alloc(buffer_type * buffer); 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_buffer_store(const ecl_kw_type * ecl_kw , buffer_type * buffer);
@ -149,29 +144,29 @@ extern "C" {
void ecl_kw_copy_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * src_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); 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); #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( int );
ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float ) ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float );
ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double ) ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double );
#undef ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER #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); #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( int );
ECL_KW_SCALE_TYPED_HEADER( float ) ECL_KW_SCALE_TYPED_HEADER( float );
ECL_KW_SCALE_TYPED_HEADER( double ) ECL_KW_SCALE_TYPED_HEADER( double );
#undef ECL_KW_SCALE_TYPED_HEADER #undef ECL_KW_SCALE_TYPED_HEADER
void ecl_kw_scale_float_or_double( ecl_kw_type * ecl_kw , double scale_factor ); 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); #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( int );
ECL_KW_SHIFT_TYPED_HEADER( float ) ECL_KW_SHIFT_TYPED_HEADER( float );
ECL_KW_SHIFT_TYPED_HEADER( double ) ECL_KW_SHIFT_TYPED_HEADER( double );
#undef ECL_KW_SHIFT_TYPED_HEADER #undef ECL_KW_SHIFT_TYPED_HEADER
void ecl_kw_shift_float_or_double( ecl_kw_type * ecl_kw , double shift_value ); 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); #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(double);
ECL_KW_IGET_TYPED_HEADER(float); ECL_KW_IGET_TYPED_HEADER(float);
ECL_KW_IGET_TYPED_HEADER(int); ECL_KW_IGET_TYPED_HEADER(int);
@ -179,7 +174,7 @@ extern "C" {
bool ecl_kw_iget_bool( const ecl_kw_type * ecl_kw , int i ); 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 ); #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(double);
ECL_KW_ISET_TYPED_HEADER(float); ECL_KW_ISET_TYPED_HEADER(float);
ECL_KW_ISET_TYPED_HEADER(int); ECL_KW_ISET_TYPED_HEADER(int);
@ -187,7 +182,7 @@ extern "C" {
void ecl_kw_iset_bool( ecl_kw_type * ecl_kw , int i , bool bool_value); 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 *); #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(double);
ECL_KW_GET_TYPED_PTR_HEADER(float); ECL_KW_GET_TYPED_PTR_HEADER(float);
ECL_KW_GET_TYPED_PTR_HEADER(int); ECL_KW_GET_TYPED_PTR_HEADER(int);
@ -195,31 +190,31 @@ extern "C" {
#undef ECL_KW_GET_TYPED_PTR_HEADER #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); #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( double );
ECL_KW_SET_INDEXED_HEADER( float ); ECL_KW_SET_INDEXED_HEADER( float );
ECL_KW_SET_INDEXED_HEADER( int ); ECL_KW_SET_INDEXED_HEADER( int );
#undef ECL_KW_SET_INDEXED_HEADER #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); #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( int );
ECL_KW_SHIFT_INDEXED_HEADER( float ) ECL_KW_SHIFT_INDEXED_HEADER( float );
ECL_KW_SHIFT_INDEXED_HEADER( double ) ECL_KW_SHIFT_INDEXED_HEADER( double );
#undef ECL_KW_SHIFT_INDEXED_HEADER #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); #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( int );
ECL_KW_SCALE_INDEXED_HEADER( float ) ECL_KW_SCALE_INDEXED_HEADER( float );
ECL_KW_SCALE_INDEXED_HEADER( double ) ECL_KW_SCALE_INDEXED_HEADER( double );
#undef ECL_KW_SCALE_INDEXED_HEADER #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); #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( int );
ECL_KW_MAX_MIN_HEADER( float ) ECL_KW_MAX_MIN_HEADER( float );
ECL_KW_MAX_MIN_HEADER( double ) ECL_KW_MAX_MIN_HEADER( double );
#undef ECL_KW_MAX_MIN_HEADER #undef ECL_KW_MAX_MIN_HEADER
#include <ecl_kw_grdecl.h> #include <ecl_kw_grdecl.h>

View File

@ -255,6 +255,9 @@ extern "C" {
/* Common keywords */ /* Common keywords */
#define SPECGRID_KW "SPECGRID" #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 #define MAPAXES_KW "MAPAXES" /* Keyword used to transform from grid coordinates to
world coordinates. */ world coordinates. */
#define LGR_KW "LGR" /* Name of LGR; for GRID files it can contain two elements, #define LGR_KW "LGR" /* Name of LGR; for GRID files it can contain two elements,

View File

@ -44,7 +44,8 @@ typedef struct ecl_smspec_struct ecl_smspec_type;
ecl_smspec_install_gen_key() must be updated. ecl_smspec_install_gen_key() must be updated.
*/ */
const int_vector_type * ecl_smspec_get_index_map( const ecl_smspec_type * smspec ); 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 ); 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 ); 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_num( ecl_smspec_var_type var_type );
@ -112,7 +113,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type;
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); 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); stringlist_type * ecl_smspec_alloc_matching_general_var_list(const ecl_smspec_type * smspec , const char * pattern);

View File

@ -173,6 +173,8 @@ typedef struct ecl_sum_struct ecl_sum_type;
void ecl_sum_fwrite( const ecl_sum_type * ecl_sum ); void ecl_sum_fwrite( const ecl_sum_type * ecl_sum );
void ecl_sum_fwrite_smspec( const ecl_sum_type * ecl_sum ); void ecl_sum_fwrite_smspec( const ecl_sum_type * ecl_sum );
smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , int num , const char * unit , float default_value); smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , int num , const char * unit , float default_value);
smspec_node_type * ecl_sum_add_blank_var( ecl_sum_type * ecl_sum , float default_value);
void ecl_sum_init_var( ecl_sum_type * ecl_sum , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num , const char * unit);
ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_days); ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_days);
void ecl_sum_update_wgname( ecl_sum_type * ecl_sum , smspec_node_type * node , const char * wgname ); void ecl_sum_update_wgname( ecl_sum_type * ecl_sum , smspec_node_type * node , const char * wgname );

View File

@ -131,6 +131,7 @@ typedef struct matrix_struct matrix_type;
double matrix_trace(const matrix_type *matrix); double matrix_trace(const matrix_type *matrix);
double matrix_diag_std(const matrix_type * Sk,double mean); double matrix_diag_std(const matrix_type * Sk,double mean);
double matrix_det3( const matrix_type * A); double matrix_det3( const matrix_type * A);
double matrix_det4( const matrix_type * A);
#ifdef HAVE_ISFINITE #ifdef HAVE_ISFINITE
bool matrix_is_finite(const matrix_type * matrix); bool matrix_is_finite(const matrix_type * matrix);

View File

@ -27,8 +27,6 @@ extern "C" {
typedef struct path_fmt_struct path_fmt_type; typedef struct path_fmt_struct path_fmt_type;
path_fmt_type * path_fmt_safe_cast(const void * arg);
path_fmt_type * path_fmt_alloc_directory_fmt(const char * ); path_fmt_type * path_fmt_alloc_directory_fmt(const char * );
path_fmt_type * path_fmt_alloc_path_fmt(const char * ); path_fmt_type * path_fmt_alloc_path_fmt(const char * );
path_fmt_type * path_fmt_copyc(const path_fmt_type *); path_fmt_type * path_fmt_copyc(const path_fmt_type *);
@ -36,6 +34,7 @@ path_fmt_type * path_fmt_scanf_alloc(const char * , int , const node_ctype * ,
char * path_fmt_alloc_path(const path_fmt_type * , bool , ...); char * path_fmt_alloc_path(const path_fmt_type * , bool , ...);
char * path_fmt_alloc_file(const path_fmt_type * , bool , ...); char * path_fmt_alloc_file(const path_fmt_type * , bool , ...);
void path_fmt_free(path_fmt_type * ); void path_fmt_free(path_fmt_type * );
void path_fmt_free__( void * arg );
const char * path_fmt_get_fmt(const path_fmt_type * ); const char * path_fmt_get_fmt(const path_fmt_type * );
void path_fmt_reset_fmt(path_fmt_type * , const char * ); void path_fmt_reset_fmt(path_fmt_type * , const char * );
void path_fmt_make_path(const path_fmt_type * ); void path_fmt_make_path(const path_fmt_type * );

View File

@ -68,6 +68,15 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
char * smspec_alloc_local_completion_key( const char * join_string, const char * keyword , const char * lgr_name , const char * wgname , int i , int j , int k); char * smspec_alloc_local_completion_key( const char * join_string, const char * keyword , const char * lgr_name , const char * wgname , int i , int j , int k);
bool smspec_node_init( smspec_node_type * smspec_node,
ecl_smspec_var_type var_type ,
const char * wgname ,
const char * keyword ,
const char * unit ,
const char * key_join_string ,
const int grid_dims[3] ,
int num);
smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type , smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type ,
const char * wgname , const char * wgname ,
@ -87,6 +96,7 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
int param_index, int param_index,
float default_value); float default_value);
smspec_node_type * smspec_node_alloc_new(int params_index, float default_value);
void smspec_node_free( smspec_node_type * index ); void smspec_node_free( smspec_node_type * index );
void smspec_node_free__(void * arg); void smspec_node_free__(void * arg);
@ -100,12 +110,16 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
void smspec_node_update_wgname( smspec_node_type * index , const char * wgname , const char * key_join_string); void smspec_node_update_wgname( smspec_node_type * index , const char * wgname , const char * key_join_string);
const char * smspec_node_get_keyword( const smspec_node_type * smspec_node); const char * smspec_node_get_keyword( const smspec_node_type * smspec_node);
const char * smspec_node_get_unit( const smspec_node_type * smspec_node); const char * smspec_node_get_unit( const smspec_node_type * smspec_node);
void smspec_node_set_unit( smspec_node_type * smspec_node , const char * unit );
bool smspec_node_is_rate( const smspec_node_type * smspec_node ); bool smspec_node_is_rate( const smspec_node_type * smspec_node );
bool smspec_node_is_total( const smspec_node_type * smspec_node ); bool smspec_node_is_total( const smspec_node_type * smspec_node );
bool smspec_node_need_nums( const smspec_node_type * smspec_node ); bool smspec_node_need_nums( const smspec_node_type * smspec_node );
float smspec_node_get_default_value( const smspec_node_type * smspec_node );
void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream); void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream);
void smspec_node_set_default( smspec_node_type * smspec_node , float default_value);
float smspec_node_get_default( const smspec_node_type * smspec_node);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -18,8 +18,8 @@
#ifndef __THREAD_POOL_H__ #ifndef __THREAD_POOL_H__
#define __THREAD_POOL_H__ #define __THREAD_POOL_H__
#ifdef HAVE_PTHREAD #ifdef WITH_PTHREAD
#define HAVE_THREAD_POOL #define WITH_THREAD_POOL
#include "thread_pool_posix.h" #include "thread_pool_posix.h"
#endif #endif

View File

@ -405,7 +405,7 @@ const char * util_enum_iget( int index , int size , const util_enum_element_type
/*****************************************************************/ /*****************************************************************/
/* Conditional section below here */ /* Conditional section below here */
#ifdef HAVE_ZLIB #ifdef WITH_ZLIB
void util_compress_buffer(const void * , int , void * , unsigned long * ); void util_compress_buffer(const void * , int , void * , unsigned long * );
int util_fread_sizeof_compressed(FILE * stream); int util_fread_sizeof_compressed(FILE * stream);
void util_fread_compressed(void * , FILE * ); void util_fread_compressed(void * , FILE * );

View File

@ -23,6 +23,7 @@
extern "C" { extern "C" {
#endif #endif
#include <node_data.h> #include <node_data.h>
#include <type_macros.h>
typedef void ( vector_func_type ) (void * , void *); typedef void ( vector_func_type ) (void * , void *);
typedef int ( vector_cmp_ftype) (const void * , const void *); typedef int ( vector_cmp_ftype) (const void * , const void *);
@ -30,8 +31,8 @@ typedef int ( vector_cmp_ftype) (const void * , const void *);
typedef struct vector_struct vector_type; typedef struct vector_struct vector_type;
vector_type * vector_alloc_new(); vector_type * vector_alloc_new();
void vector_grow_NULL( vector_type * vector , int new_size );
vector_type * vector_alloc_NULL_initialized( int size ); vector_type * vector_alloc_NULL_initialized( int size );
int vector_append_ref( vector_type * , const void *); int vector_append_ref( vector_type * , const void *);
@ -77,6 +78,7 @@ vector_type * vector_alloc_copy(const vector_type * src , bool deep_copy);
void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size);
UTIL_IS_INSTANCE_HEADER( vector );
#ifdef __cplusplus #ifdef __cplusplus
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -92,7 +92,7 @@ extern "C" {
buffer_type * buffer_fread_alloc(const char * filename); buffer_type * buffer_fread_alloc(const char * filename);
void buffer_fread_realloc(buffer_type * buffer , const char * filename); void buffer_fread_realloc(buffer_type * buffer , const char * filename);
#ifdef HAVE_ZLIB #ifdef WITH_ZLIB
size_t buffer_fwrite_compressed(buffer_type * buffer, const void * ptr , size_t byte_size); 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); size_t buffer_fread_compressed(buffer_type * buffer , size_t compressed_size , void * target_ptr , size_t target_size);
#endif #endif

View File

@ -61,11 +61,15 @@ extern "C" {
bool ecl_grid_ijk_valid(const ecl_grid_type * , int , int , int ); bool ecl_grid_ijk_valid(const ecl_grid_type * , int , int , int );
int ecl_grid_get_global_index3(const ecl_grid_type * , int , int , int ); int ecl_grid_get_global_index3(const ecl_grid_type * , int , int , int );
int ecl_grid_get_global_index1A(const ecl_grid_type * ecl_grid , int active_index); int ecl_grid_get_global_index1A(const ecl_grid_type * ecl_grid , int active_index);
ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw ); ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw );
ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , const float * mapaxes); ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , const float * mapaxes);
ecl_grid_type * ecl_grid_alloc_GRID_data(int num_coords , int nx, int ny , int nz , int coords_size , int ** coords , float ** corners , const float * mapaxes); ecl_grid_type * ecl_grid_alloc_GRID_data(int num_coords , int nx, int ny , int nz , int coords_size , int ** coords , float ** corners , const float * mapaxes);
ecl_grid_type * ecl_grid_alloc(const char * ); ecl_grid_type * ecl_grid_alloc(const char * );
ecl_grid_type * ecl_grid_load_case( const char * case_input ); ecl_grid_type * ecl_grid_load_case( const char * case_input );
ecl_grid_type * ecl_grid_alloc_rectangular( int nx , int ny , int nz , double dx , double dy , double dz , const int * actnum);
ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum);
bool ecl_grid_exists( const char * case_input ); bool ecl_grid_exists( const char * case_input );
char * ecl_grid_alloc_case_filename( const char * case_input ); char * ecl_grid_alloc_case_filename( const char * case_input );
@ -148,6 +152,9 @@ extern "C" {
ecl_kw_type * ecl_grid_alloc_hostnum_kw( const ecl_grid_type * grid ); ecl_kw_type * ecl_grid_alloc_hostnum_kw( const ecl_grid_type * grid );
ecl_kw_type * ecl_grid_alloc_gridhead_kw( int nx, int ny , int nz , int grid_nr); ecl_kw_type * ecl_grid_alloc_gridhead_kw( int nx, int ny , int nz , int grid_nr);
void ecl_grid_ri_export( const ecl_grid_type * ecl_grid , double * ri_points);
void ecl_grid_cell_ri_export( const ecl_grid_type * ecl_grid , int global_index , double * ri_points);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -103,9 +103,6 @@ extern "C" {
bool ecl_kw_is_grdecl_file(FILE * ); bool ecl_kw_is_grdecl_file(FILE * );
bool ecl_kw_is_kw_file(FILE * , bool ); bool ecl_kw_is_kw_file(FILE * , bool );
void ecl_kw_inplace_sub(ecl_kw_type * , const ecl_kw_type * );
void ecl_kw_inplace_mul(ecl_kw_type * , const ecl_kw_type * );
void ecl_kw_inplace_div(ecl_kw_type * , const ecl_kw_type * );
double ecl_kw_element_sum_float( const ecl_kw_type * ecl_kw ); 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_inplace_inv(ecl_kw_type * my_kw);
@ -113,8 +110,6 @@ extern "C" {
void ecl_kw_max_min(const ecl_kw_type * , void * , void *); void ecl_kw_max_min(const ecl_kw_type * , void * , void *);
void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw); void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw);
double ecl_kw_iget_as_double(const ecl_kw_type * , int );
ecl_kw_type * ecl_kw_buffer_alloc(buffer_type * buffer); 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_buffer_store(const ecl_kw_type * ecl_kw , buffer_type * buffer);
@ -149,29 +144,29 @@ extern "C" {
void ecl_kw_copy_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * src_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); 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); #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( int );
ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float ) ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float );
ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double ) ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double );
#undef ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER #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); #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( int );
ECL_KW_SCALE_TYPED_HEADER( float ) ECL_KW_SCALE_TYPED_HEADER( float );
ECL_KW_SCALE_TYPED_HEADER( double ) ECL_KW_SCALE_TYPED_HEADER( double );
#undef ECL_KW_SCALE_TYPED_HEADER #undef ECL_KW_SCALE_TYPED_HEADER
void ecl_kw_scale_float_or_double( ecl_kw_type * ecl_kw , double scale_factor ); 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); #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( int );
ECL_KW_SHIFT_TYPED_HEADER( float ) ECL_KW_SHIFT_TYPED_HEADER( float );
ECL_KW_SHIFT_TYPED_HEADER( double ) ECL_KW_SHIFT_TYPED_HEADER( double );
#undef ECL_KW_SHIFT_TYPED_HEADER #undef ECL_KW_SHIFT_TYPED_HEADER
void ecl_kw_shift_float_or_double( ecl_kw_type * ecl_kw , double shift_value ); 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); #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(double);
ECL_KW_IGET_TYPED_HEADER(float); ECL_KW_IGET_TYPED_HEADER(float);
ECL_KW_IGET_TYPED_HEADER(int); ECL_KW_IGET_TYPED_HEADER(int);
@ -179,7 +174,7 @@ extern "C" {
bool ecl_kw_iget_bool( const ecl_kw_type * ecl_kw , int i ); 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 ); #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(double);
ECL_KW_ISET_TYPED_HEADER(float); ECL_KW_ISET_TYPED_HEADER(float);
ECL_KW_ISET_TYPED_HEADER(int); ECL_KW_ISET_TYPED_HEADER(int);
@ -187,7 +182,7 @@ extern "C" {
void ecl_kw_iset_bool( ecl_kw_type * ecl_kw , int i , bool bool_value); 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 *); #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(double);
ECL_KW_GET_TYPED_PTR_HEADER(float); ECL_KW_GET_TYPED_PTR_HEADER(float);
ECL_KW_GET_TYPED_PTR_HEADER(int); ECL_KW_GET_TYPED_PTR_HEADER(int);
@ -195,31 +190,31 @@ extern "C" {
#undef ECL_KW_GET_TYPED_PTR_HEADER #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); #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( double );
ECL_KW_SET_INDEXED_HEADER( float ); ECL_KW_SET_INDEXED_HEADER( float );
ECL_KW_SET_INDEXED_HEADER( int ); ECL_KW_SET_INDEXED_HEADER( int );
#undef ECL_KW_SET_INDEXED_HEADER #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); #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( int );
ECL_KW_SHIFT_INDEXED_HEADER( float ) ECL_KW_SHIFT_INDEXED_HEADER( float );
ECL_KW_SHIFT_INDEXED_HEADER( double ) ECL_KW_SHIFT_INDEXED_HEADER( double );
#undef ECL_KW_SHIFT_INDEXED_HEADER #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); #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( int );
ECL_KW_SCALE_INDEXED_HEADER( float ) ECL_KW_SCALE_INDEXED_HEADER( float );
ECL_KW_SCALE_INDEXED_HEADER( double ) ECL_KW_SCALE_INDEXED_HEADER( double );
#undef ECL_KW_SCALE_INDEXED_HEADER #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); #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( int );
ECL_KW_MAX_MIN_HEADER( float ) ECL_KW_MAX_MIN_HEADER( float );
ECL_KW_MAX_MIN_HEADER( double ) ECL_KW_MAX_MIN_HEADER( double );
#undef ECL_KW_MAX_MIN_HEADER #undef ECL_KW_MAX_MIN_HEADER
#include <ecl_kw_grdecl.h> #include <ecl_kw_grdecl.h>

View File

@ -255,6 +255,9 @@ extern "C" {
/* Common keywords */ /* Common keywords */
#define SPECGRID_KW "SPECGRID" #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 #define MAPAXES_KW "MAPAXES" /* Keyword used to transform from grid coordinates to
world coordinates. */ world coordinates. */
#define LGR_KW "LGR" /* Name of LGR; for GRID files it can contain two elements, #define LGR_KW "LGR" /* Name of LGR; for GRID files it can contain two elements,

View File

@ -44,7 +44,8 @@ typedef struct ecl_smspec_struct ecl_smspec_type;
ecl_smspec_install_gen_key() must be updated. ecl_smspec_install_gen_key() must be updated.
*/ */
const int_vector_type * ecl_smspec_get_index_map( const ecl_smspec_type * smspec ); 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 ); 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 ); 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_num( ecl_smspec_var_type var_type );
@ -112,7 +113,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type;
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); 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); stringlist_type * ecl_smspec_alloc_matching_general_var_list(const ecl_smspec_type * smspec , const char * pattern);

View File

@ -173,6 +173,8 @@ typedef struct ecl_sum_struct ecl_sum_type;
void ecl_sum_fwrite( const ecl_sum_type * ecl_sum ); void ecl_sum_fwrite( const ecl_sum_type * ecl_sum );
void ecl_sum_fwrite_smspec( const ecl_sum_type * ecl_sum ); void ecl_sum_fwrite_smspec( const ecl_sum_type * ecl_sum );
smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , int num , const char * unit , float default_value); smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , int num , const char * unit , float default_value);
smspec_node_type * ecl_sum_add_blank_var( ecl_sum_type * ecl_sum , float default_value);
void ecl_sum_init_var( ecl_sum_type * ecl_sum , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num , const char * unit);
ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_days); ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_days);
void ecl_sum_update_wgname( ecl_sum_type * ecl_sum , smspec_node_type * node , const char * wgname ); void ecl_sum_update_wgname( ecl_sum_type * ecl_sum , smspec_node_type * node , const char * wgname );

View File

@ -131,6 +131,7 @@ typedef struct matrix_struct matrix_type;
double matrix_trace(const matrix_type *matrix); double matrix_trace(const matrix_type *matrix);
double matrix_diag_std(const matrix_type * Sk,double mean); double matrix_diag_std(const matrix_type * Sk,double mean);
double matrix_det3( const matrix_type * A); double matrix_det3( const matrix_type * A);
double matrix_det4( const matrix_type * A);
#ifdef HAVE_ISFINITE #ifdef HAVE_ISFINITE
bool matrix_is_finite(const matrix_type * matrix); bool matrix_is_finite(const matrix_type * matrix);

View File

@ -27,8 +27,6 @@ extern "C" {
typedef struct path_fmt_struct path_fmt_type; typedef struct path_fmt_struct path_fmt_type;
path_fmt_type * path_fmt_safe_cast(const void * arg);
path_fmt_type * path_fmt_alloc_directory_fmt(const char * ); path_fmt_type * path_fmt_alloc_directory_fmt(const char * );
path_fmt_type * path_fmt_alloc_path_fmt(const char * ); path_fmt_type * path_fmt_alloc_path_fmt(const char * );
path_fmt_type * path_fmt_copyc(const path_fmt_type *); path_fmt_type * path_fmt_copyc(const path_fmt_type *);
@ -36,6 +34,7 @@ path_fmt_type * path_fmt_scanf_alloc(const char * , int , const node_ctype * ,
char * path_fmt_alloc_path(const path_fmt_type * , bool , ...); char * path_fmt_alloc_path(const path_fmt_type * , bool , ...);
char * path_fmt_alloc_file(const path_fmt_type * , bool , ...); char * path_fmt_alloc_file(const path_fmt_type * , bool , ...);
void path_fmt_free(path_fmt_type * ); void path_fmt_free(path_fmt_type * );
void path_fmt_free__( void * arg );
const char * path_fmt_get_fmt(const path_fmt_type * ); const char * path_fmt_get_fmt(const path_fmt_type * );
void path_fmt_reset_fmt(path_fmt_type * , const char * ); void path_fmt_reset_fmt(path_fmt_type * , const char * );
void path_fmt_make_path(const path_fmt_type * ); void path_fmt_make_path(const path_fmt_type * );

View File

@ -68,6 +68,15 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
char * smspec_alloc_local_completion_key( const char * join_string, const char * keyword , const char * lgr_name , const char * wgname , int i , int j , int k); char * smspec_alloc_local_completion_key( const char * join_string, const char * keyword , const char * lgr_name , const char * wgname , int i , int j , int k);
bool smspec_node_init( smspec_node_type * smspec_node,
ecl_smspec_var_type var_type ,
const char * wgname ,
const char * keyword ,
const char * unit ,
const char * key_join_string ,
const int grid_dims[3] ,
int num);
smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type , smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type ,
const char * wgname , const char * wgname ,
@ -87,6 +96,7 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
int param_index, int param_index,
float default_value); float default_value);
smspec_node_type * smspec_node_alloc_new(int params_index, float default_value);
void smspec_node_free( smspec_node_type * index ); void smspec_node_free( smspec_node_type * index );
void smspec_node_free__(void * arg); void smspec_node_free__(void * arg);
@ -100,12 +110,16 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
void smspec_node_update_wgname( smspec_node_type * index , const char * wgname , const char * key_join_string); void smspec_node_update_wgname( smspec_node_type * index , const char * wgname , const char * key_join_string);
const char * smspec_node_get_keyword( const smspec_node_type * smspec_node); const char * smspec_node_get_keyword( const smspec_node_type * smspec_node);
const char * smspec_node_get_unit( const smspec_node_type * smspec_node); const char * smspec_node_get_unit( const smspec_node_type * smspec_node);
void smspec_node_set_unit( smspec_node_type * smspec_node , const char * unit );
bool smspec_node_is_rate( const smspec_node_type * smspec_node ); bool smspec_node_is_rate( const smspec_node_type * smspec_node );
bool smspec_node_is_total( const smspec_node_type * smspec_node ); bool smspec_node_is_total( const smspec_node_type * smspec_node );
bool smspec_node_need_nums( const smspec_node_type * smspec_node ); bool smspec_node_need_nums( const smspec_node_type * smspec_node );
float smspec_node_get_default_value( const smspec_node_type * smspec_node );
void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream); void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream);
void smspec_node_set_default( smspec_node_type * smspec_node , float default_value);
float smspec_node_get_default( const smspec_node_type * smspec_node);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -18,8 +18,8 @@
#ifndef __THREAD_POOL_H__ #ifndef __THREAD_POOL_H__
#define __THREAD_POOL_H__ #define __THREAD_POOL_H__
#ifdef HAVE_PTHREAD #ifdef WITH_PTHREAD
#define HAVE_THREAD_POOL #define WITH_THREAD_POOL
#include "thread_pool_posix.h" #include "thread_pool_posix.h"
#endif #endif

View File

@ -405,7 +405,7 @@ const char * util_enum_iget( int index , int size , const util_enum_element_type
/*****************************************************************/ /*****************************************************************/
/* Conditional section below here */ /* Conditional section below here */
#ifdef HAVE_ZLIB #ifdef WITH_ZLIB
void util_compress_buffer(const void * , int , void * , unsigned long * ); void util_compress_buffer(const void * , int , void * , unsigned long * );
int util_fread_sizeof_compressed(FILE * stream); int util_fread_sizeof_compressed(FILE * stream);
void util_fread_compressed(void * , FILE * ); void util_fread_compressed(void * , FILE * );

View File

@ -23,6 +23,7 @@
extern "C" { extern "C" {
#endif #endif
#include <node_data.h> #include <node_data.h>
#include <type_macros.h>
typedef void ( vector_func_type ) (void * , void *); typedef void ( vector_func_type ) (void * , void *);
typedef int ( vector_cmp_ftype) (const void * , const void *); typedef int ( vector_cmp_ftype) (const void * , const void *);
@ -30,8 +31,8 @@ typedef int ( vector_cmp_ftype) (const void * , const void *);
typedef struct vector_struct vector_type; typedef struct vector_struct vector_type;
vector_type * vector_alloc_new(); vector_type * vector_alloc_new();
void vector_grow_NULL( vector_type * vector , int new_size );
vector_type * vector_alloc_NULL_initialized( int size ); vector_type * vector_alloc_NULL_initialized( int size );
int vector_append_ref( vector_type * , const void *); int vector_append_ref( vector_type * , const void *);
@ -77,6 +78,7 @@ vector_type * vector_alloc_copy(const vector_type * src , bool deep_copy);
void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size);
UTIL_IS_INSTANCE_HEADER( vector );
#ifdef __cplusplus #ifdef __cplusplus
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -37,7 +37,8 @@ ScalarMapperRangeBased::ScalarMapperRangeBased()
m_rangeMax(cvf::UNDEFINED_DOUBLE), m_rangeMax(cvf::UNDEFINED_DOUBLE),
m_decadeLevelCount(1), m_decadeLevelCount(1),
m_levelCount(8), m_levelCount(8),
m_textureSize(2048) // Large enough, I guess and a power of two m_textureSize(2048), // Large enough, I guess and a power of two
m_adjustLevels(true)
{ {
m_colors.resize(m_textureSize); m_colors.resize(m_textureSize);
m_colors.setAll(Color3ub::WHITE); m_colors.setAll(Color3ub::WHITE);

View File

@ -99,7 +99,7 @@ void AnimationToolBar::init()
addAction(m_animSkipToStartAction); addAction(m_animSkipToStartAction);
addAction(m_animStepBackwardAction); addAction(m_animStepBackwardAction);
addAction(m_animPlayBwdAction ); addAction(m_animPlayBwdAction );
addAction(m_animStopAction); //addAction(m_animStopAction);
addAction(m_animPauseAction); addAction(m_animPauseAction);
addAction(m_animPlayAction); addAction(m_animPlayAction);
addAction(m_animStepForwardAction); addAction(m_animStepForwardAction);

View File

@ -19,6 +19,8 @@ set( QOBJECT_HEADERS
cafPdmUiFilePathEditor.h cafPdmUiFilePathEditor.h
cafPdmUiListEditor.h cafPdmUiListEditor.h
cafPdmUiSliderEditor.h cafPdmUiSliderEditor.h
cafPdmUiDoubleSliderEditor.h
cafPdmUiColorEditor.h cafPdmUiColorEditor.h
cafPdmUiPropertyView.h cafPdmUiPropertyView.h
@ -43,6 +45,7 @@ add_library( ${PROJECT_NAME}
cafPdmUiFilePathEditor.cpp cafPdmUiFilePathEditor.cpp
cafPdmUiListEditor.cpp cafPdmUiListEditor.cpp
cafPdmUiSliderEditor.cpp cafPdmUiSliderEditor.cpp
cafPdmUiDoubleSliderEditor.cpp
cafPdmUiColorEditor.cpp cafPdmUiColorEditor.cpp
cafPdmUiPropertyView.cpp cafPdmUiPropertyView.cpp

View File

@ -57,6 +57,7 @@ void PdmUiCheckBoxEditor::configureAndUpdateUi(const QString& uiConfigName)
m_label->setVisible(!field()->isUiHidden(uiConfigName)); m_label->setVisible(!field()->isUiHidden(uiConfigName));
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_label->setToolTip(field()->uiToolTip(uiConfigName));
m_checkBox->setEnabled(!field()->isUiReadOnly(uiConfigName)); m_checkBox->setEnabled(!field()->isUiReadOnly(uiConfigName));

View File

@ -0,0 +1,218 @@
//##################################################################################################
//
// 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 "cafPdmUiDoubleSliderEditor.h"
#include "cafPdmUiDefaultObjectEditor.h"
#include "cafPdmObject.h"
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmField.h"
#include "cafFactory.h"
#include <QLineEdit>
#include <QLabel>
#include <QHBoxLayout>
#include <QDoubleValidator>
#include <QDebug>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class PdmDoubleValidator : public QDoubleValidator
{
public:
PdmDoubleValidator(QObject * parent = 0) : QDoubleValidator(parent)
{
}
PdmDoubleValidator(double bottom, double top, int decimals, QObject * parent)
: QDoubleValidator(bottom, top, decimals, parent)
{
}
~PdmDoubleValidator()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
virtual void fixup(QString& stringValue) const
{
double doubleValue = stringValue.toDouble();
doubleValue = qBound(bottom(), doubleValue, top());
stringValue = QString::number(doubleValue, 'g', decimals());
}
};
namespace caf
{
CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT(PdmUiDoubleSliderEditor);
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiDoubleSliderEditor::configureAndUpdateUi(const QString& uiConfigName)
{
assert(!m_lineEdit.isNull());
QIcon ic = field()->uiIcon(uiConfigName);
if (!ic.isNull())
{
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
}
else
{
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setVisible(!field()->isUiHidden(uiConfigName));
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_slider->setEnabled(!field()->isUiReadOnly(uiConfigName));
field()->ownerObject()->editorAttribute(field(), uiConfigName, &m_attributes);
PdmDoubleValidator* pdmValidator = new PdmDoubleValidator(m_attributes.m_minimum, m_attributes.m_maximum, m_attributes.m_decimals, this);
m_lineEdit->setValidator(pdmValidator);
QString textValue = field()->uiValue().toString();
pdmValidator->fixup(textValue);
m_lineEdit->setText(textValue);
updateSliderPosition();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiDoubleSliderEditor::createEditorWidget(QWidget * parent)
{
QWidget* containerWidget = new QWidget(parent);
QHBoxLayout* layout = new QHBoxLayout();
layout->setMargin(0);
containerWidget->setLayout(layout);
m_lineEdit = new QLineEdit(containerWidget);
m_lineEdit->setMaximumWidth(100);
connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
m_slider = new QSlider(Qt::Horizontal, containerWidget);
layout->addWidget(m_lineEdit);
layout->addWidget(m_slider);
connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(slotSliderValueChanged(int)));
return containerWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiDoubleSliderEditor::createLabelWidget(QWidget * parent)
{
m_label = new QLabel(parent);
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiDoubleSliderEditor::slotEditingFinished()
{
updateSliderPosition();
writeValueToField();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiDoubleSliderEditor::slotSliderValueChanged(int value)
{
double newDoubleValue = convertFromSliderValue(value);
m_lineEdit->setText(QString::number(newDoubleValue));
writeValueToField();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiDoubleSliderEditor::updateSliderPosition()
{
QString textValue = m_lineEdit->text();
bool convertOk = false;
double newSliderValue = textValue.toDouble(&convertOk);
int newSliderPosition = convertToSliderValue(newSliderValue);
if (m_slider->value() != newSliderPosition)
{
m_slider->blockSignals(true);
m_slider->setValue(newSliderPosition);
m_slider->blockSignals(false);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiDoubleSliderEditor::writeValueToField()
{
QString textValue = m_lineEdit->text();
QVariant v;
v = textValue;
this->setValueToField(v);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int PdmUiDoubleSliderEditor::convertToSliderValue(double value)
{
double exactSliderValue = m_slider->maximum() * (value - m_attributes.m_minimum) / (m_attributes.m_maximum - m_attributes.m_minimum);
int sliderValue = static_cast<int>(exactSliderValue);
sliderValue = qBound(m_slider->minimum(), sliderValue, m_slider->maximum());
return sliderValue;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double PdmUiDoubleSliderEditor::convertFromSliderValue(int sliderValue)
{
double newDoubleValue = m_attributes.m_minimum + sliderValue * (m_attributes.m_maximum - m_attributes.m_minimum) / m_slider->maximum();
newDoubleValue = qBound(m_attributes.m_minimum, newDoubleValue, m_attributes.m_maximum);
return newDoubleValue;
}
} // end namespace caf

View File

@ -0,0 +1,90 @@
//##################################################################################################
//
// 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 "cafPdmUiFieldEditorHandle.h"
#include <QString>
#include <QLabel>
#include <QWidget>
#include <QPointer>
#include <QLineEdit>
#include <QGroupBox>
#include <QSlider>
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class PdmUiDoubleSliderEditorAttribute : public PdmUiEditorAttribute
{
public:
PdmUiDoubleSliderEditorAttribute()
{
m_minimum = 0;
m_maximum = 10;
m_decimals = 6;
}
public:
double m_minimum;
double m_maximum;
int m_decimals;
};
class PdmUiDoubleSliderEditor : public PdmUiFieldEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
public:
PdmUiDoubleSliderEditor() {}
virtual ~PdmUiDoubleSliderEditor() {}
protected:
virtual void configureAndUpdateUi(const QString& uiConfigName);
virtual QWidget* createEditorWidget(QWidget * parent);
virtual QWidget* createLabelWidget(QWidget * parent);
protected slots:
void slotEditingFinished();
void slotSliderValueChanged(int value);
private:
void updateSliderPosition();
void writeValueToField();
int convertToSliderValue(double value);
double convertFromSliderValue(int sliderValue);
private:
QPointer<QLineEdit> m_lineEdit;
QPointer<QSlider> m_slider;
QPointer<QLabel> m_label;
PdmUiDoubleSliderEditorAttribute m_attributes;
};
} // end namespace caf

View File

@ -122,11 +122,21 @@ void PdmUiFilePathEditor::slotEditingFinished()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void PdmUiFilePathEditor::fileSelectionClicked() void PdmUiFilePathEditor::fileSelectionClicked()
{ {
QString defaultPath;
if ( m_lineEdit->text().isEmpty())
{
defaultPath = QDir::homePath();
}
else
{
defaultPath = m_lineEdit->text();
}
if (m_attributes.m_selectDirectory) if (m_attributes.m_selectDirectory)
{ {
QString directoryPath = QFileDialog::getExistingDirectory(m_lineEdit, QString directoryPath = QFileDialog::getExistingDirectory(m_lineEdit,
tr("Get existing directory"), tr("Get existing directory"),
m_lineEdit->text(), defaultPath,
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (!directoryPath.isEmpty()) if (!directoryPath.isEmpty())
@ -140,11 +150,11 @@ void PdmUiFilePathEditor::fileSelectionClicked()
QString filePath; QString filePath;
if (m_attributes.m_selectSaveFileName) if (m_attributes.m_selectSaveFileName)
{ {
filePath = QFileDialog::getSaveFileName(m_lineEdit, tr("Save File"), m_lineEdit->text(), m_attributes.m_fileSelectionFilter); filePath = QFileDialog::getSaveFileName(m_lineEdit, tr("Save File"), defaultPath, m_attributes.m_fileSelectionFilter);
} }
else else
{ {
filePath = QFileDialog::getOpenFileName(m_lineEdit, tr("Choose a file"), m_lineEdit->text(), m_attributes.m_fileSelectionFilter); filePath = QFileDialog::getOpenFileName(m_lineEdit, tr("Choose a file"), defaultPath, m_attributes.m_fileSelectionFilter);
} }
if (!filePath.isEmpty()) if (!filePath.isEmpty())

View File

@ -263,6 +263,8 @@ static bool isWrongThread()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void ProgressInfoStatic::start(int maxProgressValue, const QString& title) void ProgressInfoStatic::start(int maxProgressValue, const QString& title)
{ {
if (!qApp) return;
if (isWrongThread()) return; if (isWrongThread()) return;
if (!maxProgressStack().size()) if (!maxProgressStack().size())

View File

@ -315,7 +315,17 @@ bool UiTreeModelPdm::removeRows(int position, int rows, const QModelIndex &paren
{ {
if (rows <= 0) return true; if (rows <= 0) return true;
PdmUiTreeItem* parentItem = getTreeItemFromIndex(parent); PdmUiTreeItem* parentItem = NULL;
if (parent.isValid())
{
parentItem = getTreeItemFromIndex(parent);
}
else
{
parentItem = m_root;
}
if (!parentItem) return true;
bool success = true; bool success = true;