///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017- Statoil ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // // See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RifPerforationIntervalReader.h" #include "RiaTextStringTools.h" #include #include const QString PERFORATION_KEY( "perforation" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::map> RifPerforationIntervalReader::readPerforationIntervals( const QStringList& filePaths ) { std::map> perforationIntervals; foreach ( QString filePath, filePaths ) { readFileIntoMap( filePath, &perforationIntervals ); } return perforationIntervals; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::map> RifPerforationIntervalReader::readPerforationIntervals( const QString& filePath ) { std::map> perforationIntervals; readFileIntoMap( filePath, &perforationIntervals ); return perforationIntervals; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RifPerforationIntervalReader::readFileIntoMap( const QString& filePath, std::map>* perforations ) { QFile data( filePath ); if ( !data.open( QFile::ReadOnly ) ) { return; } QString wellName; do { QString line = data.readLine(); if ( line.startsWith( "--" ) ) { // Skip comment continue; } // Replace any tabs with spaces to enable splitting on spaces line.replace( "\t", " " ); QStringList parts = RiaTextStringTools::splitSkipEmptyParts( line ); if ( line.startsWith( "WELLNAME" ) ) { // Save current well name if ( parts.size() > 1 ) { wellName = parts[1].trimmed(); } } else if ( parts.size() >= 6 ) { RifPerforationInterval interval; int mdStartIndex; if ( parts[3] == PERFORATION_KEY ) { interval.date = QDate::fromString( QString( "%1 %2 %3" ).arg( parts[0] ).arg( parts[1] ).arg( parts[2] ), "dd MMM yyyy" ); interval.startOfHistory = false; mdStartIndex = 4; } else if ( parts[1] == PERFORATION_KEY ) { interval.startOfHistory = true; mdStartIndex = 2; } else { continue; } interval.startMD = parts[mdStartIndex].toDouble(); interval.endMD = parts[mdStartIndex + 1].toDouble(); interval.diameter = parts[mdStartIndex + 2].toDouble(); interval.skinFactor = parts[mdStartIndex + 3].toDouble(); auto match = perforations->find( wellName ); if ( match == perforations->end() ) { ( *perforations )[wellName] = std::vector(); } ( *perforations )[wellName].push_back( interval ); } } while ( !data.atEnd() ); }