#2122 Formation/Well Path: Add new reader. Same pattern as WellPathFile

This commit is contained in:
Unknown 2017-11-24 09:42:07 +01:00 committed by Rebecca Cox
parent 800ac30d81
commit 7e28039ffd
8 changed files with 234 additions and 51 deletions

View File

@ -39,7 +39,8 @@ ${CEE_CURRENT_LIST_DIR}RifDataSourceForRftPltQMetaType.h
${CEE_CURRENT_LIST_DIR}RifEclipseUserDataKeywordTools.h ${CEE_CURRENT_LIST_DIR}RifEclipseUserDataKeywordTools.h
${CEE_CURRENT_LIST_DIR}RifCsvUserData.h ${CEE_CURRENT_LIST_DIR}RifCsvUserData.h
${CEE_CURRENT_LIST_DIR}RifCsvUserDataParser.h ${CEE_CURRENT_LIST_DIR}RifCsvUserDataParser.h
${CEE_CURRENT_LIST_DIR}RifWellFormationReader.h ${CEE_CURRENT_LIST_DIR}RifWellPathFormationReader.h
${CEE_CURRENT_LIST_DIR}RifWellPathFormationsImporter.h
# HDF5 file reader is directly included in ResInsight main CmakeList.txt # HDF5 file reader is directly included in ResInsight main CmakeList.txt
#${CEE_CURRENT_LIST_DIR}RifHdf5Reader.h #${CEE_CURRENT_LIST_DIR}RifHdf5Reader.h
) )
@ -83,7 +84,8 @@ ${CEE_CURRENT_LIST_DIR}RifDataSourceForRftPlt.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseUserDataKeywordTools.cpp ${CEE_CURRENT_LIST_DIR}RifEclipseUserDataKeywordTools.cpp
${CEE_CURRENT_LIST_DIR}RifCsvUserData.cpp ${CEE_CURRENT_LIST_DIR}RifCsvUserData.cpp
${CEE_CURRENT_LIST_DIR}RifCsvUserDataParser.cpp ${CEE_CURRENT_LIST_DIR}RifCsvUserDataParser.cpp
${CEE_CURRENT_LIST_DIR}RifWellFormationReader.cpp ${CEE_CURRENT_LIST_DIR}RifWellPathFormationReader.cpp
${CEE_CURRENT_LIST_DIR}RifWellPathFormationsImporter.cpp
# HDF5 file reader is directly included in ResInsight main CmakeList.txt # HDF5 file reader is directly included in ResInsight main CmakeList.txt
#${CEE_CURRENT_LIST_DIR}RifHdf5Reader.cpp #${CEE_CURRENT_LIST_DIR}RifHdf5Reader.cpp

View File

@ -1,46 +1,32 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2017- Statoil ASA // Copyright (C) 2017- Statoil ASA
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RifWellFormationReader.h" #include "RifWellPathFormationReader.h"
#include <QFile> #include <QFile>
#include <QStringList>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::map<QString, std::vector<RifWellFormation> > RifWellFormationReader::readWellFormations(const QStringList& filePaths) std::map<QString, std::vector<std::pair<double, QString>>> RifWellPathFormationReader::readWellFormations(const QString& filePath)
{ {
std::map<QString, std::vector<RifWellFormation>> formations; std::map<QString, std::vector<std::pair<double, QString>>> formations;
foreach (QString filePath, filePaths)
{
readFileIntoMap(filePath, &formations);
}
return formations;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<QString, std::vector<RifWellFormation> > RifWellFormationReader::readWellFormations(const QString& filePath)
{
std::map<QString, std::vector<RifWellFormation> > formations;
readFileIntoMap(filePath, &formations); readFileIntoMap(filePath, &formations);
@ -48,9 +34,31 @@ std::map<QString, std::vector<RifWellFormation> > RifWellFormationReader::readWe
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RifWellFormationReader::readFileIntoMap(const QString& filePath, std::map<QString, std::vector<RifWellFormation>>* formations) std::map<QString, cvf::ref<RigWellPathFormations>> RifWellPathFormationReader::readWellFormationsToGeometry(const QString& filePath)
{
std::map<QString, cvf::ref<RigWellPathFormations>> result;
std::map<QString, std::vector<std::pair<double, QString>>> formations;
readFileIntoMap(filePath, &formations);
std::map<QString, std::vector<std::pair<double, QString>>>::iterator it;
for (it = formations.begin(); it != formations.end(); it++)
{
cvf::ref<RigWellPathFormations> wellPathFormations = new RigWellPathFormations(it->second);
result[it->first] = wellPathFormations;
}
return result;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifWellPathFormationReader::readFileIntoMap(const QString& filePath,
std::map<QString, std::vector<std::pair<double, QString>>>* formations)
{ {
QFile data(filePath); QFile data(filePath);
@ -62,18 +70,18 @@ void RifWellFormationReader::readFileIntoMap(const QString& filePath, std::map<Q
while (header.size() < 3) while (header.size() < 3)
{ {
QString line = data.readLine().toLower(); QString line = data.readLine().toLower();
QString lineWithoutSpaces = line.remove(' '); QString lineWithoutSpaces = line.remove(' ');
header = lineWithoutSpaces.split(';', QString::KeepEmptyParts); header = lineWithoutSpaces.split(';', QString::KeepEmptyParts);
} }
const QString wellNameText = "wellname"; const QString wellNameText = "wellname";
const QString surfaceNameText = "surfacename"; const QString surfaceNameText = "surfacename";
const QString measuredDepthText = "md"; const QString measuredDepthText = "md";
int wellNameIndex = header.indexOf(wellNameText); int wellNameIndex = header.indexOf(wellNameText);
int surfaceNameIndex = header.indexOf(surfaceNameText); int surfaceNameIndex = header.indexOf(surfaceNameText);
int measuredDepthIndex = header.indexOf(measuredDepthText); int measuredDepthIndex = header.indexOf(measuredDepthText);
if (wellNameIndex == -1 || surfaceNameIndex == -1 || measuredDepthIndex == -1) if (wellNameIndex == -1 || surfaceNameIndex == -1 || measuredDepthIndex == -1)
@ -81,15 +89,19 @@ void RifWellFormationReader::readFileIntoMap(const QString& filePath, std::map<Q
return; return;
} }
do { do
{
QString line = data.readLine(); QString line = data.readLine();
QStringList dataLine = line.split(';', QString::KeepEmptyParts); QStringList dataLine = line.split(';', QString::KeepEmptyParts);
if (dataLine.size() != header.size()) continue; if (dataLine.size() != header.size())
continue;
RifWellFormation formation(dataLine[wellNameIndex], dataLine[surfaceNameIndex], dataLine[measuredDepthIndex].toDouble()); QString wellName = dataLine[wellNameIndex];
QString surfaceName = dataLine[surfaceNameIndex];
double measuredDepth = dataLine[measuredDepthIndex].toDouble();
(*formations)[formation.wellName].push_back(formation); (*formations)[wellName].push_back(std::make_pair(measuredDepth, surfaceName));
} while (!data.atEnd()); } while (!data.atEnd());
} }

View File

@ -18,30 +18,26 @@
#pragma once #pragma once
#include "RigWellPathFormations.h"
#include <map> #include <map>
#include <vector> #include <vector>
#include <utility>
#include <QStringList> #include "cvfBase.h"
#include "cvfObject.h"
struct RifWellFormation #include <QString>
{
RifWellFormation(QString wellName, QString surfaceName, double measuredDepth)
:wellName(wellName), surfaceName(surfaceName), measuredDepth(measuredDepth) {};
QString wellName;
QString surfaceName;
double measuredDepth;
};
//================================================================================================== //==================================================================================================
/// ///
//================================================================================================== //==================================================================================================
class RifWellFormationReader class RifWellPathFormationReader
{ {
public: public:
static std::map<QString, std::vector<RifWellFormation> > readWellFormations(const QStringList& filePaths); static std::map<QString, std::vector<std::pair<double, QString>> > readWellFormations(const QString& filePath);
static std::map<QString, std::vector<RifWellFormation> > readWellFormations(const QString& filePath); static std::map<QString, cvf::ref<RigWellPathFormations> > readWellFormationsToGeometry(const QString& filePath);
private: private:
static void readFileIntoMap(const QString& filePath, std::map<QString, std::vector<RifWellFormation> >* formations); static void readFileIntoMap(const QString& filePath, std::map<QString, std::vector<std::pair<double, QString>> >* formations);
}; };

View File

@ -0,0 +1,47 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RifWellPathFormationsImporter.h"
#include "RifWellPathFormationReader.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigWellPathFormations> RifWellPathFormationsImporter::readWellPathFormations(const QString& formationFilePath,
const QString& wellName)
{
readAllWellPathFormations(formationFilePath);
return m_fileNameToWellPathFormationMap[formationFilePath][wellName];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifWellPathFormationsImporter::readAllWellPathFormations(const QString& filePath)
{
// If we have the file in the map, assume it is already read.
if (m_fileNameToWellPathFormationMap.find(filePath) != m_fileNameToWellPathFormationMap.end())
{
return;
}
std::map<QString, cvf::ref<RigWellPathFormations>> wellPathToFormationMap =
RifWellPathFormationReader::readWellFormationsToGeometry(filePath);
m_fileNameToWellPathFormationMap[filePath] = wellPathToFormationMap;
}

View File

@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RigWellPathFormations.h"
#include "cvfBase.h"
#include "cvfObject.h"
#include <QDateTime>
#include <QString>
#include <map>
#include <vector>
//==================================================================================================
///
///
//==================================================================================================
class RifWellPathFormationsImporter
{
public:
cvf::ref<RigWellPathFormations> readWellPathFormations(const QString& formationFilePath, const QString& wellName);
private:
void readAllWellPathFormations(const QString& filePath);
std::map<QString /*filename*/, std::map<QString /*wellName*/, cvf::ref<RigWellPathFormations>>>
m_fileNameToWellPathFormationMap;
};

View File

@ -65,6 +65,7 @@ ${CEE_CURRENT_LIST_DIR}RigTransmissibilityEquations.h
${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.h ${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.h
${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.h ${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.h
${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.h ${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.h
${CEE_CURRENT_LIST_DIR}RigWellPathFormations.h
) )
if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES)
@ -136,6 +137,7 @@ ${CEE_CURRENT_LIST_DIR}RigTransmissibilityEquations.cpp
${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.cpp ${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.cpp
${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.cpp ${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.cpp
${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.cpp ${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.cpp
${CEE_CURRENT_LIST_DIR}RigWellPathFormations.cpp
) )
if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES)

View File

@ -0,0 +1,37 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigWellPathFormations.h"
#include "RifWellPathFormationReader.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellPathFormations::RigWellPathFormations(std::vector<std::pair<double, QString>> measuredDepthAndFormationNames)
{
m_measuredDepthAndFormationNames = measuredDepthAndFormationNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigWellPathFormations::wellName() const
{
return m_wellName;
}

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include <map>
#include <vector>
#include <QString>
#include <utility>
class RigWellPathFormations : public cvf::Object
{
public:
RigWellPathFormations(std::vector<std::pair<double, QString>> measuredDepthAndFormationNames);
QString wellName() const;
private:
QString m_wellName;
std::vector<std::pair<double, QString>> m_measuredDepthAndFormationNames;
};