mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-12 08:25:03 -05:00
#4169 Saturation-Pressure plot : Whitespace
This commit is contained in:
1 parent
8845c456bc
commit
ea9503d065
1 file changed
+86
-61
@@ -36,11 +36,11 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QTextStream>
|
||||
#include <QDebug>
|
||||
|
||||
#include "ert/ecl/ecl_box.hpp"
|
||||
#include "ert/ecl/ecl_kw.h"
|
||||
@@ -51,25 +51,15 @@ QString editKeyword("EDIT");
|
||||
QString gridKeyword("GRID");
|
||||
QString pathsKeyword("PATHS");
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Constructor
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifEclipseInputFileTools::RifEclipseInputFileTools()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RifEclipseInputFileTools::RifEclipseInputFileTools() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Destructor
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifEclipseInputFileTools::~RifEclipseInputFileTools()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RifEclipseInputFileTools::~RifEclipseInputFileTools() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -78,7 +68,7 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC
|
||||
{
|
||||
CVF_ASSERT(eclipseCase);
|
||||
|
||||
std::vector< RifKeywordAndFilePos > keywordsAndFilePos;
|
||||
std::vector<RifKeywordAndFilePos> keywordsAndFilePos;
|
||||
findKeywordsOnFile(fileName, &keywordsAndFilePos);
|
||||
|
||||
qint64 coordPos = -1;
|
||||
@@ -113,7 +103,6 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
FILE* gridFilePointer = util_fopen(fileName.toLatin1().data(), "r");
|
||||
if (!gridFilePointer) return false;
|
||||
|
||||
@@ -122,10 +111,9 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC
|
||||
// DIMENS - Is what Eclipse expects and uses, but is not defined in the GRID section and is not (?) available normally
|
||||
// ZCORN, COORD, ACTNUM, MAPAXES
|
||||
|
||||
//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_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_kw_type* specGridKw = nullptr;
|
||||
ecl_kw_type* zCornKw = nullptr;
|
||||
@@ -136,27 +124,29 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC
|
||||
// Try to read all the needed keywords. Early exit if some are not found
|
||||
caf::ProgressInfo progress(8, "Read Grid from Eclipse Input file");
|
||||
|
||||
|
||||
|
||||
bool allKwReadOk = true;
|
||||
|
||||
fseek(gridFilePointer, specgridPos, SEEK_SET);
|
||||
allKwReadOk = allKwReadOk && nullptr != (specGridKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_INT_TYPE)));
|
||||
allKwReadOk = allKwReadOk && nullptr != (specGridKw = ecl_kw_fscanf_alloc_current_grdecl__(
|
||||
gridFilePointer, false, ecl_type_create_from_type(ECL_INT_TYPE)));
|
||||
progress.setProgress(1);
|
||||
|
||||
fseek(gridFilePointer, zcornPos, SEEK_SET);
|
||||
allKwReadOk = allKwReadOk && nullptr != (zCornKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_FLOAT_TYPE)));
|
||||
allKwReadOk = allKwReadOk && nullptr != (zCornKw = ecl_kw_fscanf_alloc_current_grdecl__(
|
||||
gridFilePointer, false, ecl_type_create_from_type(ECL_FLOAT_TYPE)));
|
||||
progress.setProgress(2);
|
||||
|
||||
fseek(gridFilePointer, coordPos, SEEK_SET);
|
||||
allKwReadOk = allKwReadOk && nullptr != (coordKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_FLOAT_TYPE)));
|
||||
allKwReadOk = allKwReadOk && nullptr != (coordKw = ecl_kw_fscanf_alloc_current_grdecl__(
|
||||
gridFilePointer, false, ecl_type_create_from_type(ECL_FLOAT_TYPE)));
|
||||
progress.setProgress(3);
|
||||
|
||||
// If ACTNUM is not defined, this pointer will be nullptr, which is a valid condition
|
||||
if (actnumPos >= 0)
|
||||
{
|
||||
fseek(gridFilePointer, actnumPos, SEEK_SET);
|
||||
allKwReadOk = allKwReadOk && nullptr != (actNumKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_INT_TYPE)));
|
||||
allKwReadOk = allKwReadOk && nullptr != (actNumKw = ecl_kw_fscanf_alloc_current_grdecl__(
|
||||
gridFilePointer, false, ecl_type_create_from_type(ECL_INT_TYPE)));
|
||||
progress.setProgress(4);
|
||||
}
|
||||
|
||||
@@ -164,16 +154,16 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC
|
||||
if (mapaxesPos >= 0)
|
||||
{
|
||||
fseek(gridFilePointer, mapaxesPos, SEEK_SET);
|
||||
mapAxesKw = ecl_kw_fscanf_alloc_current_grdecl__( gridFilePointer, false , ecl_type_create_from_type(ECL_FLOAT_TYPE));
|
||||
mapAxesKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false, ecl_type_create_from_type(ECL_FLOAT_TYPE));
|
||||
}
|
||||
|
||||
if (!allKwReadOk)
|
||||
{
|
||||
if(specGridKw) ecl_kw_free(specGridKw);
|
||||
if(zCornKw) ecl_kw_free(zCornKw);
|
||||
if(coordKw) ecl_kw_free(coordKw);
|
||||
if(actNumKw) ecl_kw_free(actNumKw);
|
||||
if(mapAxesKw) ecl_kw_free(mapAxesKw);
|
||||
if (specGridKw) ecl_kw_free(specGridKw);
|
||||
if (zCornKw) ecl_kw_free(zCornKw);
|
||||
if (coordKw) ecl_kw_free(coordKw);
|
||||
if (actNumKw) ecl_kw_free(actNumKw);
|
||||
if (mapAxesKw) ecl_kw_free(mapAxesKw);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -184,7 +174,7 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC
|
||||
int ny = ecl_kw_iget_int(specGridKw, 1);
|
||||
int nz = ecl_kw_iget_int(specGridKw, 2);
|
||||
|
||||
ecl_grid_type* inputGrid = ecl_grid_alloc_GRDECL_kw( nx, ny, nz, zCornKw, coordKw, actNumKw, mapAxesKw );
|
||||
ecl_grid_type* inputGrid = ecl_grid_alloc_GRDECL_kw(nx, ny, nz, zCornKw, coordKw, actNumKw, mapAxesKw);
|
||||
|
||||
progress.setProgress(6);
|
||||
|
||||
@@ -218,7 +208,6 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Read known properties from the input file
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -236,7 +225,7 @@ std::map<QString, QString> RifEclipseInputFileTools::readProperties(const QStrin
|
||||
|
||||
FILE* gridFilePointer = util_fopen(fileName.toLatin1().data(), "r");
|
||||
|
||||
if (!gridFilePointer || !fileKeywords.size() )
|
||||
if (!gridFilePointer || !fileKeywords.size())
|
||||
{
|
||||
return std::map<QString, QString>();
|
||||
}
|
||||
@@ -248,7 +237,8 @@ std::map<QString, QString> RifEclipseInputFileTools::readProperties(const QStrin
|
||||
|
||||
fseek(gridFilePointer, fileKeywords[i].filePos, SEEK_SET);
|
||||
|
||||
ecl_kw_type* eclipseKeywordData = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false, ecl_type_create_from_type(ECL_FLOAT_TYPE));
|
||||
ecl_kw_type* eclipseKeywordData =
|
||||
ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false, ecl_type_create_from_type(ECL_FLOAT_TYPE));
|
||||
if (eclipseKeywordData)
|
||||
{
|
||||
QString newResultName = caseData->results(RiaDefines::MATRIX_MODEL)->makeResultNameUnique(fileKeywords[i].keyword);
|
||||
@@ -267,12 +257,14 @@ std::map<QString, QString> RifEclipseInputFileTools::readProperties(const QStrin
|
||||
return newResults;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Reads the property data requested into the \a reservoir, overwriting any previous
|
||||
/// properties with the same name.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigEclipseCaseData* caseData, const QString& eclipseKeyWord, const QString& resultName)
|
||||
bool RifEclipseInputFileTools::readProperty(const QString& fileName,
|
||||
RigEclipseCaseData* caseData,
|
||||
const QString& eclipseKeyWord,
|
||||
const QString& resultName)
|
||||
{
|
||||
CVF_ASSERT(caseData);
|
||||
|
||||
@@ -281,7 +273,8 @@ bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigEclipseC
|
||||
FILE* filePointer = util_fopen(fileName.toLatin1().data(), "r");
|
||||
if (!filePointer) return false;
|
||||
|
||||
ecl_kw_type* eclipseKeywordData = ecl_kw_fscanf_alloc_grdecl_dynamic__(filePointer, eclipseKeyWord.toLatin1().data(), false, ecl_type_create_from_type(ECL_FLOAT_TYPE));
|
||||
ecl_kw_type* eclipseKeywordData = ecl_kw_fscanf_alloc_grdecl_dynamic__(
|
||||
filePointer, eclipseKeyWord.toLatin1().data(), false, ecl_type_create_from_type(ECL_FLOAT_TYPE));
|
||||
bool isOk = false;
|
||||
if (eclipseKeywordData)
|
||||
{
|
||||
@@ -298,7 +291,9 @@ bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigEclipseC
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEclipseInputFileTools::readDataFromKeyword(ecl_kw_type* eclipseKeywordData, RigEclipseCaseData* caseData, const QString& resultName)
|
||||
bool RifEclipseInputFileTools::readDataFromKeyword(ecl_kw_type* eclipseKeywordData,
|
||||
RigEclipseCaseData* caseData,
|
||||
const QString& resultName)
|
||||
{
|
||||
CVF_ASSERT(caseData);
|
||||
CVF_ASSERT(eclipseKeywordData);
|
||||
@@ -318,10 +313,11 @@ bool RifEclipseInputFileTools::readDataFromKeyword(ecl_kw_type* eclipseKeywordDa
|
||||
|
||||
if (!mathingItemCount) return false;
|
||||
|
||||
RigEclipseResultAddress resAddr( RiaDefines::INPUT_PROPERTY, resultName);
|
||||
caseData->results(RiaDefines::MATRIX_MODEL)->createResultEntry( resAddr, false);
|
||||
RigEclipseResultAddress resAddr(RiaDefines::INPUT_PROPERTY, resultName);
|
||||
caseData->results(RiaDefines::MATRIX_MODEL)->createResultEntry(resAddr, false);
|
||||
|
||||
std::vector< std::vector<double> >& newPropertyData = caseData->results(RiaDefines::MATRIX_MODEL)->modifiableCellScalarResultTimesteps(resAddr);
|
||||
std::vector<std::vector<double>>& newPropertyData =
|
||||
caseData->results(RiaDefines::MATRIX_MODEL)->modifiableCellScalarResultTimesteps(resAddr);
|
||||
|
||||
newPropertyData.push_back(std::vector<double>());
|
||||
newPropertyData[0].resize(ecl_kw_get_size(eclipseKeywordData), HUGE_VAL);
|
||||
@@ -341,7 +337,7 @@ bool RifEclipseInputFileTools::readDataFromKeyword(ecl_kw_type* eclipseKeywordDa
|
||||
// https://bugreports.qt-project.org/browse/QTBUG-9814
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseInputFileTools::findKeywordsOnFile(const QString &fileName, std::vector< RifKeywordAndFilePos >* keywords)
|
||||
void RifEclipseInputFileTools::findKeywordsOnFile(const QString& fileName, std::vector<RifKeywordAndFilePos>* keywords)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
@@ -376,17 +372,17 @@ void RifEclipseInputFileTools::findKeywordsOnFile(const QString &fileName, std::
|
||||
|
||||
keyPos.keyword = keywordCandidate;
|
||||
keywords->push_back(keyPos);
|
||||
//qDebug() << keyPos.keyword << " - " << keyPos.filePos;
|
||||
// qDebug() << keyPos.keyword << " - " << keyPos.filePos;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (lineLength != -1);
|
||||
} while (lineLength != -1);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseInputFileTools::parseAndReadPathAliasKeyword(const QString &fileName, std::vector< std::pair<QString, QString> >* pathAliasDefinitions)
|
||||
void RifEclipseInputFileTools::parseAndReadPathAliasKeyword(const QString& fileName,
|
||||
std::vector<std::pair<QString, QString>>* pathAliasDefinitions)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
@@ -475,7 +471,12 @@ const std::vector<QString>& RifEclipseInputFileTools::invalidPropertyDataKeyword
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseInputFileTools::findGridKeywordPositions(const std::vector< RifKeywordAndFilePos >& keywordsAndFilePos, qint64* coordPos, qint64* zcornPos, qint64* specgridPos, qint64* actnumPos, qint64* mapaxesPos)
|
||||
void RifEclipseInputFileTools::findGridKeywordPositions(const std::vector<RifKeywordAndFilePos>& keywordsAndFilePos,
|
||||
qint64* coordPos,
|
||||
qint64* zcornPos,
|
||||
qint64* specgridPos,
|
||||
qint64* actnumPos,
|
||||
qint64* mapaxesPos)
|
||||
{
|
||||
CVF_ASSERT(coordPos && zcornPos && specgridPos && actnumPos && mapaxesPos);
|
||||
|
||||
@@ -508,7 +509,9 @@ void RifEclipseInputFileTools::findGridKeywordPositions(const std::vector< RifKe
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseInputFileTools::readFaults(const QString& fileName, const std::vector<RifKeywordAndFilePos>& fileKeywords, cvf::Collection<RigFault>* faults)
|
||||
void RifEclipseInputFileTools::readFaults(const QString& fileName,
|
||||
const std::vector<RifKeywordAndFilePos>& fileKeywords,
|
||||
cvf::Collection<RigFault>* faults)
|
||||
{
|
||||
QFile data(fileName);
|
||||
if (!data.open(QFile::ReadOnly))
|
||||
@@ -562,7 +565,10 @@ void RifEclipseInputFileTools::parseAndReadFaults(const QString& fileName, cvf::
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseInputFileTools::readFaultsInGridSection(const QString& fileName, cvf::Collection<RigFault>* faults, std::vector<QString>* filenamesWithFaults, const QString& faultIncludeFileAbsolutePathPrefix)
|
||||
void RifEclipseInputFileTools::readFaultsInGridSection(const QString& fileName,
|
||||
cvf::Collection<RigFault>* faults,
|
||||
std::vector<QString>* filenamesWithFaults,
|
||||
const QString& faultIncludeFileAbsolutePathPrefix)
|
||||
{
|
||||
QFile data(fileName);
|
||||
if (!data.open(QFile::ReadOnly))
|
||||
@@ -579,13 +585,18 @@ void RifEclipseInputFileTools::readFaultsInGridSection(const QString& fileName,
|
||||
|
||||
bool isEditKeywordDetected = false;
|
||||
|
||||
std::vector< std::pair<QString, QString> > pathAliasDefinitions;
|
||||
std::vector<std::pair<QString, QString>> pathAliasDefinitions;
|
||||
parseAndReadPathAliasKeyword(fileName, &pathAliasDefinitions);
|
||||
|
||||
readFaultsAndParseIncludeStatementsRecursively(data, gridPos, pathAliasDefinitions, faults, filenamesWithFaults, &isEditKeywordDetected, faultIncludeFileAbsolutePathPrefix);
|
||||
readFaultsAndParseIncludeStatementsRecursively(data,
|
||||
gridPos,
|
||||
pathAliasDefinitions,
|
||||
faults,
|
||||
filenamesWithFaults,
|
||||
&isEditKeywordDetected,
|
||||
faultIncludeFileAbsolutePathPrefix);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -628,7 +639,6 @@ qint64 RifEclipseInputFileTools::findKeyword(const QString& keyword, QFile& file
|
||||
|
||||
} while (!file.atEnd());
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -652,9 +662,10 @@ bool RifEclipseInputFileTools::isValidDataKeyword(const QString& keyword)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEclipseInputFileTools::readFaultsAndParseIncludeStatementsRecursively( QFile& file,
|
||||
bool RifEclipseInputFileTools::readFaultsAndParseIncludeStatementsRecursively(
|
||||
QFile& file,
|
||||
qint64 startPos,
|
||||
const std::vector< std::pair<QString, QString> >& pathAliasDefinitions,
|
||||
const std::vector<std::pair<QString, QString>>& pathAliasDefinitions,
|
||||
cvf::Collection<RigFault>* faults,
|
||||
std::vector<QString>* filenamesWithFaults,
|
||||
bool* isEditKeywordDetected,
|
||||
@@ -734,9 +745,15 @@ bool RifEclipseInputFileTools::readFaultsAndParseIncludeStatementsRecursively(
|
||||
QFile includeFile(absoluteFilename);
|
||||
if (includeFile.open(QFile::ReadOnly))
|
||||
{
|
||||
//qDebug() << "Found include statement, and start parsing of\n " << absoluteFilename;
|
||||
// qDebug() << "Found include statement, and start parsing of\n " << absoluteFilename;
|
||||
|
||||
if (!readFaultsAndParseIncludeStatementsRecursively(includeFile, 0, pathAliasDefinitions, faults, filenamesWithFaults, isEditKeywordDetected, faultIncludeFileAbsolutePathPrefix))
|
||||
if (!readFaultsAndParseIncludeStatementsRecursively(includeFile,
|
||||
0,
|
||||
pathAliasDefinitions,
|
||||
faults,
|
||||
filenamesWithFaults,
|
||||
isEditKeywordDetected,
|
||||
faultIncludeFileAbsolutePathPrefix))
|
||||
{
|
||||
qDebug() << "Error when parsing include file : " << absoluteFilename;
|
||||
}
|
||||
@@ -805,7 +822,10 @@ cvf::StructGridInterface::FaceEnum RifEclipseInputFileTools::faceEnumFromText(co
|
||||
/// Parse content of this keyword until end of file or
|
||||
/// end of keyword when a single line with '/' is found
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseInputFileTools::readFaults(QFile &data, qint64 filePos, cvf::Collection<RigFault>* faults, bool* isEditKeywordDetected)
|
||||
void RifEclipseInputFileTools::readFaults(QFile& data,
|
||||
qint64 filePos,
|
||||
cvf::Collection<RigFault>* faults,
|
||||
bool* isEditKeywordDetected)
|
||||
{
|
||||
if (!data.seek(filePos))
|
||||
{
|
||||
@@ -871,7 +891,12 @@ void RifEclipseInputFileTools::readFaults(QFile &data, qint64 filePos, cvf::Coll
|
||||
|
||||
// Adjust from 1-based to 0-based cell indices
|
||||
// Guard against invalid cell ranges by limiting lowest possible range value to zero
|
||||
cvf::CellRange cellrange(CVF_MAX(i1 - 1, 0), CVF_MAX(j1 - 1, 0), CVF_MAX(k1 - 1, 0), CVF_MAX(i2 - 1, 0), CVF_MAX(j2 - 1, 0), CVF_MAX(k2 - 1, 0));
|
||||
cvf::CellRange cellrange(CVF_MAX(i1 - 1, 0),
|
||||
CVF_MAX(j1 - 1, 0),
|
||||
CVF_MAX(k1 - 1, 0),
|
||||
CVF_MAX(i2 - 1, 0),
|
||||
CVF_MAX(j2 - 1, 0),
|
||||
CVF_MAX(k2 - 1, 0));
|
||||
|
||||
if (!(fault && fault->name() == name))
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user