mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Import of AICD valve definition from text file
* Add readKeywordContentFromFile * Add import of AICD values from Completor and Eclipse
This commit is contained in:
@@ -1181,16 +1181,15 @@ bool RifEclipseInputFileTools::readFaultsAndParseIncludeStatementsRecursively( Q
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively(
|
||||
const QString& keyword,
|
||||
const QString& keywordToStopParsing,
|
||||
QFile& file,
|
||||
qint64 startPos,
|
||||
const std::vector<std::pair<QString, QString>>& pathAliasDefinitions,
|
||||
QStringList* keywordDataContent,
|
||||
std::vector<QString>* filenamesContainingKeyword,
|
||||
bool* isStopParsingKeywordDetected,
|
||||
const QString& faultIncludeFileAbsolutePathPrefix /* rename to includeStatementAbsolutePathPrefix */ )
|
||||
bool RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively( const QString& keyword,
|
||||
const QString& keywordToStopParsing,
|
||||
const std::vector<std::pair<QString, QString>>& pathAliasDefinitions,
|
||||
const QString& includeStatementAbsolutePathPrefix,
|
||||
QFile& file,
|
||||
qint64 startPos,
|
||||
QStringList& keywordDataContent,
|
||||
std::vector<QString>& filenamesContainingKeyword,
|
||||
bool& isStopParsingKeywordDetected )
|
||||
{
|
||||
QString line;
|
||||
|
||||
@@ -1213,10 +1212,7 @@ bool RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively(
|
||||
|
||||
if ( !keywordToStopParsing.isEmpty() && line.startsWith( keywordToStopParsing, Qt::CaseInsensitive ) )
|
||||
{
|
||||
if ( isStopParsingKeywordDetected )
|
||||
{
|
||||
*isStopParsingKeywordDetected = true;
|
||||
}
|
||||
isStopParsingKeywordDetected = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1256,7 +1252,7 @@ bool RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively(
|
||||
if ( includeFilename.startsWith( '/' ) )
|
||||
{
|
||||
// Absolute UNIX path, prefix on Windows
|
||||
includeFilename = faultIncludeFileAbsolutePathPrefix + includeFilename;
|
||||
includeFilename = includeStatementAbsolutePathPrefix + includeFilename;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1267,17 +1263,15 @@ bool RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively(
|
||||
QFile includeFile( absoluteFilename );
|
||||
if ( includeFile.open( QFile::ReadOnly ) )
|
||||
{
|
||||
// qDebug() << "Found include statement, and start parsing of\n " << absoluteFilename;
|
||||
|
||||
if ( !readKeywordAndParseIncludeStatementsRecursively( keyword,
|
||||
keywordToStopParsing,
|
||||
pathAliasDefinitions,
|
||||
includeStatementAbsolutePathPrefix,
|
||||
includeFile,
|
||||
0,
|
||||
pathAliasDefinitions,
|
||||
keywordDataContent,
|
||||
filenamesContainingKeyword,
|
||||
isStopParsingKeywordDetected,
|
||||
faultIncludeFileAbsolutePathPrefix ) )
|
||||
isStopParsingKeywordDetected ) )
|
||||
{
|
||||
qDebug() << "Error when parsing include file : " << absoluteFilename;
|
||||
}
|
||||
@@ -1290,11 +1284,11 @@ bool RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively(
|
||||
if ( !line.contains( "/" ) )
|
||||
{
|
||||
readKeywordDataContent( file, file.pos(), keywordDataContent, isStopParsingKeywordDetected );
|
||||
filenamesContainingKeyword->push_back( file.fileName() );
|
||||
filenamesContainingKeyword.push_back( file.fileName() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isStopParsingKeywordDetected && *isStopParsingKeywordDetected )
|
||||
if ( isStopParsingKeywordDetected )
|
||||
{
|
||||
continueParsing = false;
|
||||
}
|
||||
@@ -1312,7 +1306,7 @@ bool RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively(
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseInputFileTools::readKeywordDataContent( QFile& data, qint64 filePos, QStringList* textContent, bool* isEditKeywordDetected )
|
||||
void RifEclipseInputFileTools::readKeywordDataContent( QFile& data, qint64 filePos, QStringList& textContent, bool& isStopParsingKeywordDetected )
|
||||
{
|
||||
if ( !data.seek( filePos ) )
|
||||
{
|
||||
@@ -1340,11 +1334,7 @@ void RifEclipseInputFileTools::readKeywordDataContent( QFile& data, qint64 fileP
|
||||
else if ( line.startsWith( editKeyword, Qt::CaseInsensitive ) )
|
||||
{
|
||||
// End parsing when edit keyword is detected
|
||||
|
||||
if ( isEditKeywordDetected )
|
||||
{
|
||||
*isEditKeywordDetected = true;
|
||||
}
|
||||
isStopParsingKeywordDetected = true;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1356,7 +1346,7 @@ void RifEclipseInputFileTools::readKeywordDataContent( QFile& data, qint64 fileP
|
||||
|
||||
if ( !line.isEmpty() )
|
||||
{
|
||||
textContent->push_back( line );
|
||||
textContent.push_back( line );
|
||||
}
|
||||
|
||||
} while ( !data.atEnd() );
|
||||
@@ -1369,7 +1359,7 @@ RiaDefines::EclipseUnitSystem RifEclipseInputFileTools::readUnitSystem( QFile& f
|
||||
{
|
||||
bool stopParsing = false;
|
||||
QStringList unitText;
|
||||
readKeywordDataContent( file, gridunitPos, &unitText, &stopParsing );
|
||||
readKeywordDataContent( file, gridunitPos, unitText, stopParsing );
|
||||
for ( QString unitString : unitText )
|
||||
{
|
||||
if ( unitString.contains( "FEET", Qt::CaseInsensitive ) )
|
||||
@@ -1437,6 +1427,31 @@ bool RifEclipseInputFileTools::hasGridData( const QString& fileName )
|
||||
return coordKeywordItr != keywordAndValues.end();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList RifEclipseInputFileTools::readKeywordContentFromFile( const QString& keyword, const QString& keywordToStopParsing, QFile& file )
|
||||
{
|
||||
std::vector<std::pair<QString, QString>> pathAliasDefinitions;
|
||||
const QString includeStatementAbsolutePathPrefix;
|
||||
const qint64 startPositionInFile = 0;
|
||||
QStringList keywordContent;
|
||||
std::vector<QString> fileNamesContainingKeyword;
|
||||
bool isStopParsingKeywordDetected = false;
|
||||
|
||||
RifEclipseInputFileTools::readKeywordAndParseIncludeStatementsRecursively( keyword,
|
||||
keywordToStopParsing,
|
||||
pathAliasDefinitions,
|
||||
includeStatementAbsolutePathPrefix,
|
||||
file,
|
||||
startPositionInFile,
|
||||
keywordContent,
|
||||
fileNamesContainingKeyword,
|
||||
isStopParsingKeywordDetected );
|
||||
|
||||
return keywordContent;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// The file pointer is pointing at the line following the FAULTS keyword.
|
||||
/// Parse content of this keyword until end of file or
|
||||
|
||||
Reference in New Issue
Block a user