mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#736) Added support for basic metadata and basic value queries
This commit is contained in:
parent
1d9405b266
commit
4b33c31a0f
@ -9,9 +9,11 @@ ${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools.h
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseOutputFileTools.h
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.h
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.h
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryTools.h
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary.h
|
||||
${CEE_CURRENT_LIST_DIR}RifJsonEncodeDecode.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderInterface.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderMockModel.h
|
||||
@ -24,8 +26,10 @@ ${CEE_CURRENT_LIST_DIR}RifEclipseOutputFileTools.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryTools.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifJsonEncodeDecode.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderInterface.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderMockModel.cpp
|
||||
|
133
ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp
Normal file
133
ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp
Normal file
@ -0,0 +1,133 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 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 "RifEclipseSummaryTools.h"
|
||||
|
||||
#include "RifReaderEclipseSummary.h"
|
||||
|
||||
#include "ecl_util.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseSummaryTools::findSummaryHeaderFile(const std::string& inputFile, std::string* headerFile, bool* isFormatted)
|
||||
{
|
||||
findSummaryHeaderFileInfo(inputFile, headerFile, NULL, NULL, isFormatted);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::string> RifEclipseSummaryTools::findSummaryDataFiles(const std::string& caseFile)
|
||||
{
|
||||
std::vector<std::string> fileNames;
|
||||
|
||||
std::string path;
|
||||
std::string base;
|
||||
|
||||
findSummaryHeaderFileInfo(caseFile, NULL, &path, &base, NULL);
|
||||
if (path.empty() || base.empty()) return fileNames;
|
||||
|
||||
char* header_file = NULL;
|
||||
stringlist_type* summary_file_list = stringlist_alloc_new();
|
||||
|
||||
ecl_util_alloc_summary_files(path.data(), base.data(), NULL, &header_file, summary_file_list);
|
||||
if (stringlist_get_size( summary_file_list ) > 0)
|
||||
{
|
||||
for (int i = 0; i < stringlist_get_size(summary_file_list); i++)
|
||||
{
|
||||
fileNames.push_back(stringlist_iget(summary_file_list, i));
|
||||
}
|
||||
}
|
||||
|
||||
util_safe_free(header_file);
|
||||
stringlist_free(summary_file_list);
|
||||
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseSummaryTools::dumpMetaData(RifReaderEclipseSummary* readerEclipseSummary)
|
||||
{
|
||||
std::cout << " -- Well names --" << std::endl;
|
||||
{
|
||||
std::vector<std::string> names = readerEclipseSummary->wellNames();
|
||||
|
||||
for (size_t i = 0; i < names.size(); i++)
|
||||
{
|
||||
std::cout << names[i] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << " -- Well variable names --" << std::endl;
|
||||
{
|
||||
std::vector<std::string> names = readerEclipseSummary->wellVariableNames();
|
||||
|
||||
for (size_t i = 0; i < names.size(); i++)
|
||||
{
|
||||
std::cout << names[i] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << " -- Group names --" << std::endl;
|
||||
{
|
||||
std::vector<std::string> names = readerEclipseSummary->wellGroupNames();
|
||||
|
||||
for (size_t i = 0; i < names.size(); i++)
|
||||
{
|
||||
std::cout << names[i] << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseSummaryTools::findSummaryHeaderFileInfo(const std::string& inputFile, std::string* headerFile, std::string* path, std::string* base, bool* isFormatted)
|
||||
{
|
||||
char* myPath = NULL;
|
||||
char* myBase = NULL;
|
||||
bool formattedFile = true;
|
||||
|
||||
util_alloc_file_components(inputFile.data(), &myPath, &myBase, NULL);
|
||||
|
||||
char* myHeaderFile = ecl_util_alloc_exfilename(myPath, myBase, ECL_SUMMARY_HEADER_FILE, true, -1);
|
||||
if (!myHeaderFile)
|
||||
{
|
||||
myHeaderFile = ecl_util_alloc_exfilename(myPath, myBase, ECL_SUMMARY_HEADER_FILE, false, -1);
|
||||
if (myHeaderFile)
|
||||
{
|
||||
formattedFile = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (myHeaderFile && headerFile) *headerFile = myHeaderFile;
|
||||
if (myPath && path) *path = myPath;
|
||||
if (myBase && base) *base = myBase;
|
||||
if (isFormatted) *isFormatted = formattedFile;
|
||||
|
||||
util_safe_free(myHeaderFile);
|
||||
util_safe_free(myBase);
|
||||
util_safe_free(myPath);
|
||||
}
|
41
ApplicationCode/FileInterface/RifEclipseSummaryTools.h
Normal file
41
ApplicationCode/FileInterface/RifEclipseSummaryTools.h
Normal file
@ -0,0 +1,41 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 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>
|
||||
#include <vector>
|
||||
|
||||
class RifReaderEclipseSummary;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RifEclipseSummaryTools
|
||||
{
|
||||
public:
|
||||
static void findSummaryHeaderFile(const std::string& inputFile, std::string* headerFile, bool* isFormatted);
|
||||
static std::vector<std::string> findSummaryDataFiles(const std::string& caseFile);
|
||||
|
||||
static void dumpMetaData(RifReaderEclipseSummary* readerEclipseSummary);
|
||||
|
||||
private:
|
||||
static void findSummaryHeaderFileInfo(const std::string& inputFile, std::string* headerFile, std::string* path, std::string* base, bool* isFormatted);
|
||||
};
|
238
ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp
Normal file
238
ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp
Normal file
@ -0,0 +1,238 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 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 "RifReaderEclipseSummary.h"
|
||||
|
||||
#include "ecl_sum.h"
|
||||
|
||||
#include <string>
|
||||
#include <assert.h>
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifReaderEclipseSummary::RifReaderEclipseSummary()
|
||||
: ecl_sum(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifReaderEclipseSummary::~RifReaderEclipseSummary()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifReaderEclipseSummary::open(const std::string& headerFileName, const std::vector<std::string>& dataFileNames)
|
||||
{
|
||||
assert(ecl_sum == NULL);
|
||||
assert(!headerFileName.empty());
|
||||
assert(dataFileNames.size() > 0);
|
||||
|
||||
stringlist_type* dataFiles = stringlist_alloc_new();
|
||||
for (size_t i = 0; i < dataFileNames.size(); i++)
|
||||
{
|
||||
stringlist_append_copy(dataFiles, dataFileNames[i].data());
|
||||
}
|
||||
|
||||
std::string itemSeparatorInVariableNames = ":";
|
||||
ecl_sum = ecl_sum_fread_alloc(headerFileName.data(), dataFiles, itemSeparatorInVariableNames.data());
|
||||
|
||||
stringlist_free(dataFiles);
|
||||
|
||||
if (ecl_sum)
|
||||
{
|
||||
assert(ecl_sum_get_smspec(ecl_sum) != NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifReaderEclipseSummary::close()
|
||||
{
|
||||
if (ecl_sum)
|
||||
{
|
||||
ecl_sum_free(ecl_sum);
|
||||
ecl_sum = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::string> RifReaderEclipseSummary::variableNames() const
|
||||
{
|
||||
assert(ecl_sum != NULL);
|
||||
|
||||
// Get all possible variable names from file
|
||||
stringlist_type* keys = ecl_sum_alloc_matching_general_var_list(ecl_sum, NULL);
|
||||
stringlist_sort(keys, NULL);
|
||||
|
||||
std::vector<std::string> names;
|
||||
RifReaderEclipseSummary::populateVectorFromStringList(keys, &names);
|
||||
|
||||
stringlist_free(keys);
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifReaderEclipseSummary::values(const std::string& variableName, std::vector<double>* values)
|
||||
{
|
||||
assert(ecl_sum != NULL);
|
||||
|
||||
int variableIndex = variableIndexFromVariableName(variableName);
|
||||
if (variableIndex < 0) return false;
|
||||
|
||||
for (int time_index = 0; time_index < timeStepCount(); time_index++)
|
||||
{
|
||||
double value = ecl_sum_iget(ecl_sum, time_index, variableIndex);
|
||||
|
||||
values->push_back(value);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RifReaderEclipseSummary::variableIndexFromVariableName(const std::string& keyword) const
|
||||
{
|
||||
assert(ecl_sum != NULL);
|
||||
|
||||
return ecl_sum_get_general_var_params_index(ecl_sum, keyword.data());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RifReaderEclipseSummary::timeStepCount() const
|
||||
{
|
||||
assert(ecl_sum != NULL);
|
||||
|
||||
return ecl_sum_get_data_length(ecl_sum);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::string> RifReaderEclipseSummary::wellGroupNames() const
|
||||
{
|
||||
assert(ecl_sum != NULL);
|
||||
|
||||
std::vector<std::string> names;
|
||||
stringlist_type* stringList = ecl_sum_alloc_group_list(ecl_sum, NULL);
|
||||
RifReaderEclipseSummary::populateVectorFromStringList(stringList, &names);
|
||||
|
||||
stringlist_free(stringList);
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::string> RifReaderEclipseSummary::wellNames() const
|
||||
{
|
||||
assert(ecl_sum != NULL);
|
||||
|
||||
std::vector<std::string> names;
|
||||
stringlist_type* stringList = ecl_sum_alloc_well_list(ecl_sum, NULL);
|
||||
RifReaderEclipseSummary::populateVectorFromStringList(stringList, &names);
|
||||
|
||||
stringlist_free(stringList);
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::string> RifReaderEclipseSummary::wellVariableNames() const
|
||||
{
|
||||
assert(ecl_sum != NULL);
|
||||
|
||||
std::vector<std::string> names;
|
||||
stringlist_type* stringList = ecl_sum_alloc_well_var_list(ecl_sum);
|
||||
RifReaderEclipseSummary::populateVectorFromStringList(stringList, &names);
|
||||
stringlist_free(stringList);
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<time_t> RifReaderEclipseSummary::timeSteps() const
|
||||
{
|
||||
assert(ecl_sum != NULL);
|
||||
|
||||
std::vector<time_t> steps;
|
||||
for (int time_index = 0; time_index < timeStepCount(); time_index++)
|
||||
{
|
||||
time_t sim_time = ecl_sum_iget_sim_time(ecl_sum , time_index);
|
||||
steps.push_back(sim_time);
|
||||
}
|
||||
|
||||
return steps;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QDateTime> RifReaderEclipseSummary::fromTimeT(const std::vector<time_t>& timeSteps)
|
||||
{
|
||||
std::vector<QDateTime> a;
|
||||
|
||||
for (size_t i = 0; i < timeSteps.size(); i++)
|
||||
{
|
||||
QDateTime dt = QDateTime::fromTime_t(timeSteps[i]);
|
||||
a.push_back(dt);
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifReaderEclipseSummary::populateVectorFromStringList(stringlist_type* stringList, std::vector<std::string>* strings)
|
||||
{
|
||||
assert(stringList && strings);
|
||||
|
||||
for (int i = 0; i < stringlist_get_size(stringList); i++)
|
||||
{
|
||||
strings->push_back(stringlist_iget(stringList, i));
|
||||
}
|
||||
}
|
||||
|
68
ApplicationCode/FileInterface/RifReaderEclipseSummary.h
Normal file
68
ApplicationCode/FileInterface/RifReaderEclipseSummary.h
Normal file
@ -0,0 +1,68 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 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>
|
||||
#include <vector>
|
||||
|
||||
class QDateTime;
|
||||
|
||||
// Taken from ecl_sum.h
|
||||
typedef struct ecl_sum_struct ecl_sum_type;
|
||||
|
||||
// Taken from stringlist.h
|
||||
typedef struct stringlist_struct stringlist_type;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RifReaderEclipseSummary
|
||||
{
|
||||
public:
|
||||
RifReaderEclipseSummary();
|
||||
~RifReaderEclipseSummary();
|
||||
|
||||
bool open(const std::string& headerFileName, const std::vector<std::string>& dataFileNames);
|
||||
void close();
|
||||
|
||||
std::vector<std::string> wellNames() const;
|
||||
std::vector<std::string> wellGroupNames() const;
|
||||
|
||||
std::vector<std::string> wellVariableNames() const;
|
||||
std::vector<std::string> variableNames() const;
|
||||
|
||||
std::vector<time_t> timeSteps() const;
|
||||
|
||||
bool values(const std::string& variableName, std::vector<double>* values);
|
||||
|
||||
|
||||
// TODO: Move this to a tools class with static members
|
||||
static std::vector<QDateTime> fromTimeT(const std::vector<time_t>& timeSteps);
|
||||
|
||||
private:
|
||||
int variableIndexFromVariableName(const std::string& variableName) const;
|
||||
|
||||
int timeStepCount() const;
|
||||
|
||||
static void populateVectorFromStringList(stringlist_type* stringList, std::vector<std::string>* strings);
|
||||
|
||||
private:
|
||||
ecl_sum_type* ecl_sum;
|
||||
};
|
@ -12,6 +12,7 @@ ${CEE_CURRENT_LIST_DIR}cvfGeometryTools-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}Ert-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigActiveCellInfo-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigReservoir-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigStatisticsMath-Test.cpp
|
||||
|
623
ApplicationCode/UnitTests/RifReaderEclipseSummary-Test.cpp
Normal file
623
ApplicationCode/UnitTests/RifReaderEclipseSummary-Test.cpp
Normal file
@ -0,0 +1,623 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 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 "gtest/gtest.h"
|
||||
|
||||
#include "RifReaderEclipseSummary.h"
|
||||
#include "RifEclipseSummaryTools.h"
|
||||
|
||||
#include "stringlist.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
|
||||
void printDateAndValues(const std::vector<QDateTime>& dates, const std::vector<double>& values)
|
||||
{
|
||||
EXPECT_TRUE(dates.size() == values.size());
|
||||
|
||||
for (size_t i = 0; i < values.size(); i++)
|
||||
{
|
||||
std::string dateStr = dates[i].toString("dd/MMM/yyyy").toStdString();
|
||||
|
||||
std::cout << dateStr << " " << values[i] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifEclipseSummaryTest, SummaryToolsFindSummaryFiles)
|
||||
{
|
||||
{
|
||||
std::string filename = "g:\\Models\\Statoil\\MultipleRealisations\\Case_without_p9\\Real10\\BRUGGE_0010";
|
||||
|
||||
{
|
||||
std::string headerFile;
|
||||
bool isFormatted = false;
|
||||
RifEclipseSummaryTools::findSummaryHeaderFile(filename, &headerFile, &isFormatted);
|
||||
|
||||
EXPECT_FALSE(isFormatted);
|
||||
EXPECT_FALSE(headerFile.empty());
|
||||
|
||||
std::vector<std::string> dataFiles = RifEclipseSummaryTools::findSummaryDataFiles(filename);
|
||||
EXPECT_TRUE(dataFiles.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::string filename = "g:\\Models\\Statoil\\testcase_juli_2011\\data\\TEST10K_FLT_LGR_NNC";
|
||||
|
||||
{
|
||||
std::string headerFile;
|
||||
bool isFormatted = false;
|
||||
RifEclipseSummaryTools::findSummaryHeaderFile(filename, &headerFile, &isFormatted);
|
||||
|
||||
EXPECT_FALSE(isFormatted);
|
||||
EXPECT_FALSE(headerFile.empty());
|
||||
|
||||
std::vector<std::string> dataFiles = RifEclipseSummaryTools::findSummaryDataFiles(filename);
|
||||
EXPECT_TRUE(dataFiles.size() > 0);
|
||||
|
||||
std::unique_ptr<RifReaderEclipseSummary> eclSummary = std::unique_ptr<RifReaderEclipseSummary>(new RifReaderEclipseSummary);
|
||||
eclSummary->open(headerFile, dataFiles);
|
||||
|
||||
RifEclipseSummaryTools::dumpMetaData(eclSummary.get());
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// MSJ TODO: Formatted output does not work now, should be reported?
|
||||
/*
|
||||
std::string filename = "g:\\Models\\Statoil\\Brillig\\BRILLIG_FMTOUT";
|
||||
|
||||
{
|
||||
std::string headerFile;
|
||||
bool isFormatted = false;
|
||||
RifEclipseSummaryTools::findSummaryHeaderFile(filename, &headerFile, &isFormatted);
|
||||
|
||||
EXPECT_FALSE(isFormatted);
|
||||
EXPECT_FALSE(headerFile.empty());
|
||||
|
||||
std::vector<std::string> dataFiles = RifEclipseSummaryTools::findSummaryDataFiles(filename);
|
||||
EXPECT_TRUE(dataFiles.size() > 0);
|
||||
|
||||
std::unique_ptr<RifReaderEclipseSummary> eclSummary = std::unique_ptr<RifReaderEclipseSummary>(new RifReaderEclipseSummary);
|
||||
eclSummary->open(headerFile, dataFiles);
|
||||
|
||||
RifEclipseSummaryTools::dumpMetaData(eclSummary.get());
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
{
|
||||
std::string path;
|
||||
std::string base;
|
||||
bool isFormatted = false;
|
||||
RifEclipseSummaryTools::findSummaryHeaderFile(filename, &path, &base, &isFormatted);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifEclipseSummaryTest, BasicReadKeywordTest)
|
||||
{
|
||||
std::unique_ptr<RifReaderEclipseSummary> eclSummary = std::unique_ptr<RifReaderEclipseSummary>(new RifReaderEclipseSummary);
|
||||
|
||||
std::string filename = "g:\\Models\\Statoil\\testcase_juli_2011\\data\\TEST10K_FLT_LGR_NNC";
|
||||
|
||||
std::string headerFileName;
|
||||
RifEclipseSummaryTools::findSummaryHeaderFile(filename, &headerFileName, NULL);
|
||||
|
||||
std::vector<std::string> dataFileNames = RifEclipseSummaryTools::findSummaryDataFiles(filename);
|
||||
|
||||
eclSummary->open(headerFileName, dataFileNames);
|
||||
|
||||
RifEclipseSummaryTools::dumpMetaData(eclSummary.get());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifEclipseSummaryTest, DISABLE_BasicReadKeywordTest)
|
||||
{
|
||||
std::unique_ptr<RifReaderEclipseSummary> eclSummary = std::unique_ptr<RifReaderEclipseSummary>(new RifReaderEclipseSummary);
|
||||
|
||||
std::string filename = "g:\\Models\\Statoil\\MultipleRealisations\\Case_without_p9\\Real10\\BRUGGE_0010.SMSPEC";
|
||||
std::vector<std::string> dataFileNames;
|
||||
dataFileNames.push_back("g:\\Models\\Statoil\\MultipleRealisations\\Case_without_p9\\Real10\\BRUGGE_0010.S0001");
|
||||
dataFileNames.push_back("g:\\Models\\Statoil\\MultipleRealisations\\Case_without_p9\\Real10\\BRUGGE_0010.S0002");
|
||||
dataFileNames.push_back("g:\\Models\\Statoil\\MultipleRealisations\\Case_without_p9\\Real10\\BRUGGE_0010.S0003");
|
||||
eclSummary->open(filename, dataFileNames);
|
||||
|
||||
std::cout << " -- Well names --" << std::endl;
|
||||
{
|
||||
std::vector<std::string> names = eclSummary->wellNames();
|
||||
|
||||
for (size_t i = 0; i < names.size(); i++)
|
||||
{
|
||||
std::cout << names[i] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << " -- Well variable names --" << std::endl;
|
||||
{
|
||||
std::vector<std::string> names = eclSummary->wellVariableNames();
|
||||
|
||||
for (size_t i = 0; i < names.size(); i++)
|
||||
{
|
||||
std::cout << names[i] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << " -- Group names --" << std::endl;
|
||||
{
|
||||
std::vector<std::string> names = eclSummary->wellGroupNames();
|
||||
|
||||
for (size_t i = 0; i < names.size(); i++)
|
||||
{
|
||||
std::cout << names[i] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifEclipseSummaryTest, BasicReadDataTest)
|
||||
{
|
||||
std::unique_ptr<RifReaderEclipseSummary> eclSummary = std::unique_ptr<RifReaderEclipseSummary>(new RifReaderEclipseSummary);
|
||||
|
||||
std::string filename = "g:\\Models\\Statoil\\MultipleRealisations\\Case_without_p9\\Real10\\BRUGGE_0010.SMSPEC";
|
||||
std::vector<std::string> dataFileNames;
|
||||
dataFileNames.push_back("g:\\Models\\Statoil\\MultipleRealisations\\Case_without_p9\\Real10\\BRUGGE_0010.S0001");
|
||||
dataFileNames.push_back("g:\\Models\\Statoil\\MultipleRealisations\\Case_without_p9\\Real10\\BRUGGE_0010.S0012");
|
||||
dataFileNames.push_back("g:\\Models\\Statoil\\MultipleRealisations\\Case_without_p9\\Real10\\BRUGGE_0010.S0023");
|
||||
eclSummary->open(filename, dataFileNames);
|
||||
|
||||
std::vector<QDateTime> dateTimes;
|
||||
{
|
||||
std::vector<time_t> times = eclSummary->timeSteps();
|
||||
dateTimes = RifReaderEclipseSummary::fromTimeT(times);
|
||||
}
|
||||
|
||||
{
|
||||
std::string keyword = "YEARS";
|
||||
std::cout << std::endl << keyword << std::endl;
|
||||
|
||||
std::vector<double> values;
|
||||
eclSummary->values(keyword, &values);
|
||||
printDateAndValues(dateTimes, values);
|
||||
}
|
||||
|
||||
{
|
||||
std::string keyword = "WWPR:P20";
|
||||
std::cout << std::endl << keyword << std::endl;
|
||||
|
||||
std::vector<double> values;
|
||||
eclSummary->values(keyword, &values);
|
||||
printDateAndValues(dateTimes, values);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifEclipseSummaryTest, DISABLED_StringlistSelectMatchingFiles)
|
||||
{
|
||||
std::string currentFolderName = "g:\\Models\\Statoil\\MultipleRealisations\\Case_without_p9\\Real10";
|
||||
//QDir::setCurrent(currentFolderName);
|
||||
|
||||
//std::string filename = "";
|
||||
//std::string filepattern = "BRUGGE_0010.S[0-9][0-9][0-9][0-9]";
|
||||
std::string filepattern = "BRUGGE_0010.S*";
|
||||
//std::string filepattern = "*";
|
||||
|
||||
stringlist_type* names = stringlist_alloc_new();
|
||||
|
||||
stringlist_select_matching_files(names, currentFolderName.data(), filepattern.data());
|
||||
|
||||
for (int i = 0; i < stringlist_get_size(names); i++)
|
||||
{
|
||||
std::cout << stringlist_iget(names, i) << std::endl;
|
||||
}
|
||||
|
||||
stringlist_free(names);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifEclipseSummaryTest, DISABLED_StringlistSelectMatchingFilesQuestion)
|
||||
{
|
||||
std::string currentFolderName = "g:\\Models\\Statoil\\MultipleRealisations\\Case_without_p9\\Real10";
|
||||
std::string filepattern = "BRUGGE_0010.S????";
|
||||
|
||||
stringlist_type* names = stringlist_alloc_new();
|
||||
|
||||
stringlist_select_matching_files(names, currentFolderName.data(), filepattern.data());
|
||||
|
||||
for (int i = 0; i < stringlist_get_size(names); i++)
|
||||
{
|
||||
std::cout << stringlist_iget(names, i) << std::endl;
|
||||
}
|
||||
|
||||
stringlist_free(names);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
WBHP:I01-01
|
||||
WBHP:I01-02
|
||||
WBHP:I01-03
|
||||
WBHP:I02
|
||||
WBHP:I02-01
|
||||
WBHP:I02-02
|
||||
WBHP:I02-03
|
||||
WBHP:I03
|
||||
WBHP:I03-01
|
||||
WBHP:I03-02
|
||||
WBHP:I03-03
|
||||
WBHP:I04
|
||||
WBHP:I04-01
|
||||
WBHP:I04-02
|
||||
WBHP:I04-03
|
||||
WBHP:I05
|
||||
WBHP:I05-01
|
||||
WBHP:I05-02
|
||||
WBHP:I05-03
|
||||
WBHP:I06
|
||||
WBHP:I06-01
|
||||
WBHP:I06-02
|
||||
WBHP:I06-03
|
||||
WBHP:I07
|
||||
WBHP:I07-01
|
||||
WBHP:I07-02
|
||||
WBHP:I07-03
|
||||
WBHP:I08
|
||||
WBHP:I08-01
|
||||
WBHP:I08-02
|
||||
WBHP:I08-03
|
||||
WBHP:I09
|
||||
WBHP:I09-01
|
||||
WBHP:I09-02
|
||||
WBHP:I09-03
|
||||
WBHP:I10
|
||||
WBHP:I10-01
|
||||
WBHP:I10-02
|
||||
WBHP:I10-03
|
||||
WBHP:P01
|
||||
WBHP:P01-01
|
||||
WBHP:P01-02
|
||||
WBHP:P01-03
|
||||
WBHP:P02
|
||||
WBHP:P02-01
|
||||
WBHP:P02-02
|
||||
WBHP:P02-03
|
||||
WBHP:P03
|
||||
WBHP:P03-01
|
||||
WBHP:P03-02
|
||||
WBHP:P03-03
|
||||
WBHP:P04
|
||||
WBHP:P04-01
|
||||
WBHP:P04-02
|
||||
WBHP:P04-03
|
||||
WBHP:P05
|
||||
WBHP:P05-01
|
||||
WBHP:P05-02
|
||||
WBHP:P06
|
||||
WBHP:P06-01
|
||||
WBHP:P06-02
|
||||
WBHP:P07
|
||||
WBHP:P07-01
|
||||
WBHP:P07-02
|
||||
WBHP:P07-03
|
||||
WBHP:P08
|
||||
WBHP:P08-01
|
||||
WBHP:P08-02
|
||||
WBHP:P08-03
|
||||
WBHP:P09
|
||||
WBHP:P09-01
|
||||
WBHP:P10
|
||||
WBHP:P10-01
|
||||
WBHP:P10-02
|
||||
WBHP:P11
|
||||
WBHP:P11-01
|
||||
WBHP:P11-02
|
||||
WBHP:P11-03
|
||||
WBHP:P12
|
||||
WBHP:P12-01
|
||||
WBHP:P12-02
|
||||
WBHP:P12-03
|
||||
WBHP:P13
|
||||
WBHP:P13-01
|
||||
WBHP:P13-02
|
||||
WBHP:P13-03
|
||||
WBHP:P14
|
||||
WBHP:P14-01
|
||||
WBHP:P14-02
|
||||
WBHP:P15
|
||||
WBHP:P15-01
|
||||
WBHP:P15-02
|
||||
WBHP:P16
|
||||
WBHP:P16-01
|
||||
WBHP:P16-02
|
||||
WBHP:P16-03
|
||||
WBHP:P17
|
||||
WBHP:P17-01
|
||||
WBHP:P17-02
|
||||
WBHP:P17-03
|
||||
WBHP:P18
|
||||
WBHP:P18-01
|
||||
WBHP:P18-02
|
||||
WBHP:P18-03
|
||||
WBHP:P19
|
||||
WBHP:P19-01
|
||||
WBHP:P19-02
|
||||
WBHP:P19-03
|
||||
WBHP:P20
|
||||
WBHP:P20-01
|
||||
WBHP:P20-02
|
||||
WBHP:P20-03
|
||||
WOPR:P01
|
||||
WOPR:P01-01
|
||||
WOPR:P01-02
|
||||
WOPR:P01-03
|
||||
WOPR:P02
|
||||
WOPR:P02-01
|
||||
WOPR:P02-02
|
||||
WOPR:P02-03
|
||||
WOPR:P03
|
||||
WOPR:P03-01
|
||||
WOPR:P03-02
|
||||
WOPR:P03-03
|
||||
WOPR:P04
|
||||
WOPR:P04-01
|
||||
WOPR:P04-02
|
||||
WOPR:P04-03
|
||||
WOPR:P05
|
||||
WOPR:P05-01
|
||||
WOPR:P05-02
|
||||
WOPR:P06
|
||||
WOPR:P06-01
|
||||
WOPR:P06-02
|
||||
WOPR:P07
|
||||
WOPR:P07-01
|
||||
WOPR:P07-02
|
||||
WOPR:P07-03
|
||||
WOPR:P08
|
||||
WOPR:P08-01
|
||||
WOPR:P08-02
|
||||
WOPR:P08-03
|
||||
WOPR:P09
|
||||
WOPR:P09-01
|
||||
WOPR:P10
|
||||
WOPR:P10-01
|
||||
WOPR:P10-02
|
||||
WOPR:P11
|
||||
WOPR:P11-01
|
||||
WOPR:P11-02
|
||||
WOPR:P11-03
|
||||
WOPR:P12
|
||||
WOPR:P12-01
|
||||
WOPR:P12-02
|
||||
WOPR:P12-03
|
||||
WOPR:P13
|
||||
WOPR:P13-01
|
||||
WOPR:P13-02
|
||||
WOPR:P13-03
|
||||
WOPR:P14
|
||||
WOPR:P14-01
|
||||
WOPR:P14-02
|
||||
WOPR:P15
|
||||
WOPR:P15-01
|
||||
WOPR:P15-02
|
||||
WOPR:P16
|
||||
WOPR:P16-01
|
||||
WOPR:P16-02
|
||||
WOPR:P16-03
|
||||
WOPR:P17
|
||||
WOPR:P17-01
|
||||
WOPR:P17-02
|
||||
WOPR:P17-03
|
||||
WOPR:P18
|
||||
WOPR:P18-01
|
||||
WOPR:P18-02
|
||||
WOPR:P18-03
|
||||
WOPR:P19
|
||||
WOPR:P19-01
|
||||
WOPR:P19-02
|
||||
WOPR:P19-03
|
||||
WOPR:P20
|
||||
WOPR:P20-01
|
||||
WOPR:P20-02
|
||||
WOPR:P20-03
|
||||
WWIR:I01
|
||||
WWIR:I01-01
|
||||
WWIR:I01-02
|
||||
WWIR:I01-03
|
||||
WWIR:I02
|
||||
WWIR:I02-01
|
||||
WWIR:I02-02
|
||||
WWIR:I02-03
|
||||
WWIR:I03
|
||||
WWIR:I03-01
|
||||
WWIR:I03-02
|
||||
WWIR:I03-03
|
||||
WWIR:I04
|
||||
WWIR:I04-01
|
||||
WWIR:I04-02
|
||||
WWIR:I04-03
|
||||
WWIR:I05
|
||||
WWIR:I05-01
|
||||
WWIR:I05-02
|
||||
WWIR:I05-03
|
||||
WWIR:I06
|
||||
WWIR:I06-01
|
||||
WWIR:I06-02
|
||||
WWIR:I06-03
|
||||
WWIR:I07
|
||||
WWIR:I07-01
|
||||
WWIR:I07-02
|
||||
WWIR:I07-03
|
||||
WWIR:I08
|
||||
WWIR:I08-01
|
||||
WWIR:I08-02
|
||||
WWIR:I08-03
|
||||
WWIR:I09
|
||||
WWIR:I09-01
|
||||
WWIR:I09-02
|
||||
WWIR:I09-03
|
||||
WWIR:I10
|
||||
WWIR:I10-01
|
||||
WWIR:I10-02
|
||||
WWIR:I10-03
|
||||
WWPR:P01
|
||||
WWPR:P01-01
|
||||
WWPR:P01-02
|
||||
WWPR:P01-03
|
||||
WWPR:P02
|
||||
WWPR:P02-01
|
||||
WWPR:P02-02
|
||||
WWPR:P02-03
|
||||
WWPR:P03
|
||||
WWPR:P03-01
|
||||
WWPR:P03-02
|
||||
WWPR:P03-03
|
||||
WWPR:P04
|
||||
WWPR:P04-01
|
||||
WWPR:P04-02
|
||||
WWPR:P04-03
|
||||
WWPR:P05
|
||||
WWPR:P05-01
|
||||
WWPR:P05-02
|
||||
WWPR:P06
|
||||
WWPR:P06-01
|
||||
WWPR:P06-02
|
||||
WWPR:P07
|
||||
WWPR:P07-01
|
||||
WWPR:P07-02
|
||||
WWPR:P07-03
|
||||
WWPR:P08
|
||||
WWPR:P08-01
|
||||
WWPR:P08-02
|
||||
WWPR:P08-03
|
||||
WWPR:P09
|
||||
WWPR:P09-01
|
||||
WWPR:P10
|
||||
WWPR:P10-01
|
||||
WWPR:P10-02
|
||||
WWPR:P11
|
||||
WWPR:P11-01
|
||||
WWPR:P11-02
|
||||
WWPR:P11-03
|
||||
WWPR:P12
|
||||
WWPR:P12-01
|
||||
WWPR:P12-02
|
||||
WWPR:P12-03
|
||||
WWPR:P13
|
||||
WWPR:P13-01
|
||||
WWPR:P13-02
|
||||
WWPR:P13-03
|
||||
WWPR:P14
|
||||
WWPR:P14-01
|
||||
WWPR:P14-02
|
||||
WWPR:P15
|
||||
WWPR:P15-01
|
||||
WWPR:P15-02
|
||||
WWPR:P16
|
||||
WWPR:P16-01
|
||||
WWPR:P16-02
|
||||
WWPR:P16-03
|
||||
WWPR:P17
|
||||
WWPR:P17-01
|
||||
WWPR:P17-02
|
||||
WWPR:P17-03
|
||||
WWPR:P18
|
||||
WWPR:P18-01
|
||||
WWPR:P18-02
|
||||
WWPR:P18-03
|
||||
WWPR:P19
|
||||
WWPR:P19-01
|
||||
WWPR:P19-02
|
||||
WWPR:P19-03
|
||||
WWPR:P20
|
||||
WWPR:P20-01
|
||||
WWPR:P20-02
|
||||
WWPR:P20-03
|
||||
YEARS
|
||||
*/
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifEclipseSummaryTest, DISABLED_BasicTestSetCurrentFolder)
|
||||
{
|
||||
/*
|
||||
std::unique_ptr<RifReaderEclipseSummary> eclSummary = std::unique_ptr<RifReaderEclipseSummary>(new RifReaderEclipseSummary);
|
||||
|
||||
QString currentFolderName = "g:\\Models\\Statoil\\MultipleRealisations\\Case_without_p9\\Real10";
|
||||
QDir::setCurrent(currentFolderName);
|
||||
|
||||
std::string filename = "BRUGGE_0010";
|
||||
eclSummary->open(filename);
|
||||
|
||||
std::vector<std::string> keywords;
|
||||
eclSummary->keywords(&keywords);
|
||||
|
||||
for (size_t i = 0; i < keywords.size(); i++)
|
||||
{
|
||||
std::cout << keywords[i] << std::endl;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifEclipseSummaryTest, DISABLED_BasicTest)
|
||||
{
|
||||
/*
|
||||
std::unique_ptr<RifReaderEclipseSummary> eclSummary = std::unique_ptr<RifReaderEclipseSummary>(new RifReaderEclipseSummary);
|
||||
|
||||
std::string filename = "g:\\Models\\Statoil\\MultipleRealisations\\Case_without_p9\\Real10\\BRUGGE_0010";
|
||||
eclSummary->open(filename);
|
||||
|
||||
std::vector<std::string> keywords;
|
||||
eclSummary->keywords(&keywords);
|
||||
|
||||
for (size_t i = 0; i < keywords.size(); i++)
|
||||
{
|
||||
std::cout << keywords[i] << std::endl;
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
Reference in New Issue
Block a user