#4169 Saturation-Pressure plot : Whitespace

This commit is contained in:
Magne Sjaastad committed 2019-03-05 14:18:57 +01:00
1 parent 8845c456bc
commit ea9503d065
1 file changed
+70 -45
@@ -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() {}
//--------------------------------------------------------------------------------------------------
///
@@ -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);
}
@@ -218,7 +208,6 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC
return true;
}
//--------------------------------------------------------------------------------------------------
/// Read known properties from the input file
//--------------------------------------------------------------------------------------------------
@@ -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);
@@ -321,7 +316,8 @@ bool RifEclipseInputFileTools::readDataFromKeyword(ecl_kw_type* eclipseKeywordDa
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);
@@ -379,14 +375,14 @@ void RifEclipseInputFileTools::findKeywordsOnFile(const QString &fileName, std::
// 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))
@@ -582,10 +588,15 @@ void RifEclipseInputFileTools::readFaultsInGridSection(const QString& fileName,
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,7 +662,8 @@ 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,
cvf::Collection<RigFault>* faults,
@@ -736,7 +747,13 @@ bool RifEclipseInputFileTools::readFaultsAndParseIncludeStatementsRecursively(
{
// 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))
{