mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1947 RFT/PLT Plot: Add .RFT file reader
This commit is contained in:
@@ -22,12 +22,14 @@ ${CEE_CURRENT_LIST_DIR}RifColumnBasedUserDataParser.h
|
||||
${CEE_CURRENT_LIST_DIR}RifKeywordVectorParser.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderObservedData.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderEclipseRft.h
|
||||
${CEE_CURRENT_LIST_DIR}RifJsonEncodeDecode.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderInterface.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderMockModel.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderSettings.h
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddress.h
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddressQMetaType.h
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseRftAddress.h
|
||||
${CEE_CURRENT_LIST_DIR}RifWellPathImporter.h
|
||||
${CEE_CURRENT_LIST_DIR}RifHdf5ReaderInterface.h
|
||||
${CEE_CURRENT_LIST_DIR}RifColumnBasedUserData.h
|
||||
@@ -61,11 +63,13 @@ ${CEE_CURRENT_LIST_DIR}RifColumnBasedUserDataParser.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifKeywordVectorParser.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderObservedData.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderEclipseRft.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifJsonEncodeDecode.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderInterface.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderMockModel.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderSettings.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddress.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseRftAddress.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifWellPathImporter.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifHdf5ReaderInterface.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifColumnBasedUserData.cpp
|
||||
|
43
ApplicationCode/FileInterface/RifEclipseRftAddress.cpp
Normal file
43
ApplicationCode/FileInterface/RifEclipseRftAddress.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RifEclipseRftAddress.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool operator==(const RifEclipseRftAddress& first, const RifEclipseRftAddress& second)
|
||||
{
|
||||
if (first.wellName() != second.wellName()) return false;
|
||||
if (first.timeStep() != second.timeStep()) return false;
|
||||
if (first.wellLogChannelName() != second.wellLogChannelName()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool operator<(const RifEclipseRftAddress& first, const RifEclipseRftAddress& second)
|
||||
{
|
||||
if (first.wellName() != second.wellName()) return (first.wellName() < second.wellName());
|
||||
if (first.timeStep() != second.timeStep()) return (first.timeStep() < second.timeStep());
|
||||
if (first.wellLogChannelName() != second.wellLogChannelName()) return (first.wellLogChannelName() < second.wellLogChannelName());
|
||||
|
||||
return false;
|
||||
}
|
46
ApplicationCode/FileInterface/RifEclipseRftAddress.h
Normal file
46
ApplicationCode/FileInterface/RifEclipseRftAddress.h
Normal 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 <string>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RifEclipseRftAddress
|
||||
{
|
||||
public:
|
||||
RifEclipseRftAddress(std::string wellName, time_t timeStep, std::string wellLogChannelName) :
|
||||
m_wellName(wellName), m_timeStep(timeStep), m_wellLogChannelName(wellLogChannelName) {}
|
||||
|
||||
const std::string& wellName() const { return m_wellName; }
|
||||
time_t timeStep() const { return m_timeStep; }
|
||||
const std::string& wellLogChannelName() const { return m_wellLogChannelName; }
|
||||
|
||||
private:
|
||||
std::string m_wellName;
|
||||
time_t m_timeStep;
|
||||
std::string m_wellLogChannelName;
|
||||
};
|
||||
|
||||
bool operator==(const RifEclipseRftAddress& first, const RifEclipseRftAddress& second);
|
||||
|
||||
bool operator<(const RifEclipseRftAddress& first, const RifEclipseRftAddress& second);
|
188
ApplicationCode/FileInterface/RifReaderEclipseRft.cpp
Normal file
188
ApplicationCode/FileInterface/RifReaderEclipseRft.cpp
Normal file
@@ -0,0 +1,188 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RifReaderEclipseRft.h"
|
||||
|
||||
#include "RifEclipseRftAddress.h"
|
||||
|
||||
#include "ert/ecl/ecl_rft_file.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifReaderEclipseRft::RifReaderEclipseRft()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifReaderEclipseRft::~RifReaderEclipseRft()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifReaderEclipseRft::open(const std::string& fileName)
|
||||
{
|
||||
if (fileName.empty()) return false;
|
||||
|
||||
m_ecl_rft_file = ecl_rft_file_alloc_case(fileName.data());
|
||||
|
||||
if (m_ecl_rft_file == NULL) return false;
|
||||
|
||||
int fileSize = ecl_rft_file_get_size(m_ecl_rft_file);
|
||||
|
||||
for (int i = 0; i < fileSize; i++)
|
||||
{
|
||||
ecl_rft_node_type* node = ecl_rft_file_iget_node(m_ecl_rft_file, i);
|
||||
|
||||
std::string wellName = ecl_rft_node_get_well_name(node);
|
||||
time_t timeStep = ecl_rft_node_get_date(node);
|
||||
|
||||
std::string wellLogChannelName = "PRESSURE";
|
||||
RifEclipseRftAddress addressPressure(wellName, timeStep, wellLogChannelName);
|
||||
m_eclipseRftAddresses.push_back(addressPressure);
|
||||
m_rftAddressToLibeclNodeIdx[addressPressure] = i;
|
||||
|
||||
if (ecl_rft_node_is_RFT(node))
|
||||
{
|
||||
wellLogChannelName = "SWAT";
|
||||
RifEclipseRftAddress addressSwat(wellName, timeStep, wellLogChannelName);
|
||||
m_eclipseRftAddresses.push_back(addressSwat);
|
||||
m_rftAddressToLibeclNodeIdx[addressSwat] = i;
|
||||
|
||||
wellLogChannelName = "SOIL";
|
||||
RifEclipseRftAddress addressSoil(wellName, timeStep, wellLogChannelName);
|
||||
m_eclipseRftAddresses.push_back(addressSoil);
|
||||
m_rftAddressToLibeclNodeIdx[addressSoil] = i;
|
||||
|
||||
wellLogChannelName = "SGAS";
|
||||
RifEclipseRftAddress addressSgas(wellName, timeStep, wellLogChannelName);
|
||||
m_eclipseRftAddresses.push_back(addressSgas);
|
||||
m_rftAddressToLibeclNodeIdx[addressSgas] = i;
|
||||
}
|
||||
else if (ecl_rft_node_is_PLT(node))
|
||||
{
|
||||
wellLogChannelName = "WRAT";
|
||||
RifEclipseRftAddress addressWrat(wellName, timeStep, wellLogChannelName);
|
||||
m_eclipseRftAddresses.push_back(addressWrat);
|
||||
m_rftAddressToLibeclNodeIdx[addressWrat] = i;
|
||||
|
||||
wellLogChannelName = "GRAT";
|
||||
RifEclipseRftAddress addressGrat(wellName, timeStep, wellLogChannelName);
|
||||
m_eclipseRftAddresses.push_back(addressGrat);
|
||||
m_rftAddressToLibeclNodeIdx[addressGrat] = i;
|
||||
|
||||
wellLogChannelName = "ORAT";
|
||||
RifEclipseRftAddress addressOrat(wellName, timeStep, wellLogChannelName);
|
||||
m_eclipseRftAddresses.push_back(addressOrat);
|
||||
m_rftAddressToLibeclNodeIdx[addressOrat] = i;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<RifEclipseRftAddress>& RifReaderEclipseRft::eclipseRftAddresses() const
|
||||
{
|
||||
return m_eclipseRftAddresses;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifReaderEclipseRft::values(const RifEclipseRftAddress& rftAddress, std::vector<double>* values) const
|
||||
{
|
||||
int index = indexFromAddress(rftAddress);
|
||||
if (index < 0) return;
|
||||
|
||||
ecl_rft_node_type* node = ecl_rft_file_iget_node(m_ecl_rft_file, index);
|
||||
|
||||
std::string wellLogChannelName = rftAddress.wellLogChannelName();
|
||||
|
||||
if (wellLogChannelName == "PRESSURE")
|
||||
{
|
||||
for (int i = 0; i < ecl_rft_node_get_size(node); i++)
|
||||
{
|
||||
values->push_back(ecl_rft_node_iget_pressure(node, i));
|
||||
}
|
||||
}
|
||||
else if (wellLogChannelName == "SWAT")
|
||||
{
|
||||
for (int i = 0; i < ecl_rft_node_get_size(node); i++)
|
||||
{
|
||||
values->push_back(ecl_rft_node_iget_swat(node, i));
|
||||
}
|
||||
}
|
||||
else if (wellLogChannelName == "SOIL")
|
||||
{
|
||||
for (int i = 0; i < ecl_rft_node_get_size(node); i++)
|
||||
{
|
||||
values->push_back(ecl_rft_node_iget_soil(node, i));
|
||||
}
|
||||
}
|
||||
else if (wellLogChannelName == "SGAS")
|
||||
{
|
||||
for (int i = 0; i < ecl_rft_node_get_size(node); i++)
|
||||
{
|
||||
values->push_back(ecl_rft_node_iget_sgas(node, i));
|
||||
}
|
||||
}
|
||||
else if (wellLogChannelName == "WRAT")
|
||||
{
|
||||
for (int i = 0; i < ecl_rft_node_get_size(node); i++)
|
||||
{
|
||||
values->push_back(ecl_rft_node_iget_wrat(node, i));
|
||||
}
|
||||
}
|
||||
else if (wellLogChannelName == "GRAT")
|
||||
{
|
||||
for (int i = 0; i < ecl_rft_node_get_size(node); i++)
|
||||
{
|
||||
values->push_back(ecl_rft_node_iget_grat(node, i));
|
||||
}
|
||||
}
|
||||
else if (wellLogChannelName == "ORAT")
|
||||
{
|
||||
for (int i = 0; i < ecl_rft_node_get_size(node); i++)
|
||||
{
|
||||
values->push_back(ecl_rft_node_iget_orat(node, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RifReaderEclipseRft::indexFromAddress(const RifEclipseRftAddress& rftAddress) const
|
||||
{
|
||||
auto it = m_rftAddressToLibeclNodeIdx.find(rftAddress);
|
||||
|
||||
if (it != m_rftAddressToLibeclNodeIdx.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
60
ApplicationCode/FileInterface/RifReaderEclipseRft.h
Normal file
60
ApplicationCode/FileInterface/RifReaderEclipseRft.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class RifEclipseRftAddress;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RifReaderEclipseRft
|
||||
{
|
||||
public:
|
||||
RifReaderEclipseRft();
|
||||
~RifReaderEclipseRft();
|
||||
|
||||
bool open(const std::string& fileName);
|
||||
|
||||
const std::vector<RifEclipseRftAddress>& eclipseRftAddresses() const;
|
||||
void values(const RifEclipseRftAddress& rftAddress, std::vector<double>* values) const;
|
||||
|
||||
/*const std::vector<std::string>& wellNames() const;
|
||||
std::vector<time_t> timeSteps();*/
|
||||
//void values(const std::string& wellName, size_t timeStepIndex, std::vector<double>* values) const;
|
||||
|
||||
private:
|
||||
int indexFromAddress(const RifEclipseRftAddress& rftAddress) const;
|
||||
|
||||
private:
|
||||
|
||||
// Taken from ecl_rft_file.h and ecl_rft_node.h
|
||||
typedef struct ecl_rft_file_struct ecl_rft_file_type;
|
||||
typedef struct ecl_rft_node_struct ecl_rft_node_type;
|
||||
|
||||
ecl_rft_file_type* m_ecl_rft_file;
|
||||
std::vector<RifEclipseRftAddress> m_eclipseRftAddresses;
|
||||
std::map<RifEclipseRftAddress, int> m_rftAddressToLibeclNodeIdx;
|
||||
|
||||
};
|
||||
|
40
ApplicationCode/UnitTests/EclipseRftReader-Test.cpp
Normal file
40
ApplicationCode/UnitTests/EclipseRftReader-Test.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "RifReaderEclipseRft.h"
|
||||
#include "RifEclipseRftAddress.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//TEST(RifReaderEclipseRftTest, TestRifEclipseRftAddress)
|
||||
TEST(DISABLED_RifReaderEclipseRftTest, TestRifEclipseRftAddress)
|
||||
{
|
||||
std::string filename = "C:\\Users\\Rebecca Cox\\Dropbox\\norne\\norne\\NORNE_ATW2013.RFT";
|
||||
RifReaderEclipseRft reader;
|
||||
bool ok = reader.open(filename);
|
||||
ASSERT_TRUE(ok);
|
||||
|
||||
std::vector<RifEclipseRftAddress> addresses = reader.eclipseRftAddresses();
|
||||
|
||||
/*for (RifEclipseRftAddress address : addresses)
|
||||
{
|
||||
std::cout << address.wellName() << std::endl;
|
||||
}*/
|
||||
|
||||
for (RifEclipseRftAddress address : addresses)
|
||||
{
|
||||
std::vector<double> values;
|
||||
reader.values(address, &values);
|
||||
EXPECT_TRUE(values.size() > 0);
|
||||
}
|
||||
|
||||
ASSERT_TRUE(addresses.size() > 0);
|
||||
|
||||
std::vector<double> values;
|
||||
reader.values(addresses[0], &values);
|
||||
ASSERT_TRUE(values.size() > 0);
|
||||
|
||||
std::cout << "First value: " << values.front() << ", last value: " << values.back() << std::endl;
|
||||
}
|
Reference in New Issue
Block a user