mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3588 Intersect : Add support for import of Intersect data
This commit is contained in:
parent
1215235255
commit
3b9cdf5a92
@ -478,6 +478,52 @@ void RifEclipseOutputFileTools::transferNncFluxData(const ecl_grid_type* grid,
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEclipseOutputFileTools::isExportedFromIntersect(ecl_file_type* ecl_file)
|
||||
{
|
||||
// This code is taken from ecl_file_get_ecl_version() in ecl_file.cpp
|
||||
|
||||
ecl_kw_type* intehead_kw = ecl_file_iget_named_kw(ecl_file, INTEHEAD_KW, 0);
|
||||
if (!intehead_kw) return false;
|
||||
|
||||
int int_value = ecl_kw_iget_int(intehead_kw, INTEHEAD_IPROG_INDEX);
|
||||
if (int_value == INTEHEAD_INTERSECT_VALUE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ecl_kw_type* RifEclipseOutputFileTools::createActnumFromPorv(ecl_file_type* ecl_file)
|
||||
{
|
||||
std::string porv_kw("PORV");
|
||||
|
||||
if (ecl_file_has_kw(ecl_file, porv_kw.data()))
|
||||
{
|
||||
ecl_file_view_type* fileView = ecl_file_get_global_view(ecl_file);
|
||||
|
||||
int keywordCount = ecl_file_get_num_named_kw(ecl_file, porv_kw.data());
|
||||
for (int index = 0; index < keywordCount; index++)
|
||||
{
|
||||
ecl_kw_type* fileKeyword = ecl_file_view_iget_named_kw(fileView, porv_kw.data(), index);
|
||||
if (fileKeyword)
|
||||
{
|
||||
float porvLimit = 0.0f;
|
||||
|
||||
return ecl_kw_alloc_actnum(fileKeyword, porvLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -75,6 +75,9 @@ public:
|
||||
static void transferNncFluxData(const ecl_grid_type* grid, ecl_file_view_type* summaryView,
|
||||
std::vector<double>* waterFlux, std::vector<double>* oilFlux, std::vector<double>* gasFlux);
|
||||
|
||||
static bool isExportedFromIntersect(ecl_file_type* ecl_file);
|
||||
|
||||
static ecl_kw_type* createActnumFromPorv(ecl_file_type* ecl_file);
|
||||
|
||||
private:
|
||||
static void createReportStepsMetaData(std::vector<ecl_file_type*> ecl_files, std::vector<RifRestartReportStep>* reportSteps);
|
||||
|
@ -382,9 +382,18 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigEclipseCaseData* e
|
||||
// Keep the set of files of interest
|
||||
m_filesWithSameBaseName = fileSet;
|
||||
|
||||
openInitFile();
|
||||
|
||||
// Read geometry
|
||||
// Todo: Needs to check existence of file before calling ert, else it will abort
|
||||
ecl_grid_type * mainEclGrid = ecl_grid_alloc( RiaStringEncodingTools::toNativeEncoded(fileName).data() );
|
||||
ecl_grid_type* mainEclGrid = createMainGrid();
|
||||
if (!mainEclGrid)
|
||||
{
|
||||
QString errorMessage = QString(" Failed to create a main grid from file\n%1").arg(m_fileName);
|
||||
RiaLogging::error(errorMessage);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
progInfo.incrementProgress();
|
||||
|
||||
@ -2182,6 +2191,36 @@ bool RifReaderEclipseOutput::isEclipseAndSoursimTimeStepsEqual(const QDateTime&
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ecl_grid_type* RifReaderEclipseOutput::createMainGrid() const
|
||||
{
|
||||
ecl_grid_type* mainEclGrid = nullptr;
|
||||
|
||||
{
|
||||
if (m_ecl_init_file && RifEclipseOutputFileTools::isExportedFromIntersect(m_ecl_init_file))
|
||||
{
|
||||
ecl_kw_type* actnumFromPorv = RifEclipseOutputFileTools::createActnumFromPorv(m_ecl_init_file);
|
||||
if (actnumFromPorv)
|
||||
{
|
||||
int* actnum_values = ecl_kw_get_int_ptr(actnumFromPorv);
|
||||
|
||||
mainEclGrid = ecl_grid_alloc_ext_actnum(RiaStringEncodingTools::toNativeEncoded(m_fileName).data(), actnum_values);
|
||||
|
||||
ecl_kw_free(actnumFromPorv);
|
||||
}
|
||||
}
|
||||
|
||||
if (!mainEclGrid)
|
||||
{
|
||||
mainEclGrid = ecl_grid_alloc(RiaStringEncodingTools::toNativeEncoded(m_fileName).data());
|
||||
}
|
||||
}
|
||||
|
||||
return mainEclGrid;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -95,6 +95,8 @@ private:
|
||||
|
||||
static bool isEclipseAndSoursimTimeStepsEqual(const QDateTime& eclipseDateTime, const QDateTime& sourSimDateTime);
|
||||
|
||||
ecl_grid_type* createMainGrid() const;
|
||||
|
||||
private:
|
||||
QString m_fileName; // Name of file used to start accessing Eclipse output files
|
||||
QStringList m_filesWithSameBaseName; // Set of files in filename's path with same base name as filename
|
||||
|
@ -51,6 +51,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaWeightedMean-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaWeightedGeometricMeanCalculator-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaWeightedHarmonicMeanCalculator-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaCellDividingTools-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Intersect-Test.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
43
ApplicationCode/UnitTests/Intersect-Test.cpp
Normal file
43
ApplicationCode/UnitTests/Intersect-Test.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "RifEclipseOutputFileTools.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "ert/ecl/ecl_file.h"
|
||||
#include "ert/ecl/ecl_kw_magic.h"
|
||||
#include "ert/ecl/ecl_kw.hpp"
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(IntersectDataImport, DISABLED_TestImportPORV)
|
||||
{
|
||||
QString baseFolder = "d:/Models/Statoil/IX_output_files/";
|
||||
QString filename = baseFolder + "NORNE_IX2.INIT";
|
||||
|
||||
std::string porv_kw("PORV");
|
||||
|
||||
ecl_file_type* ecl_file = ecl_file_open(filename.toStdString().data(), ECL_FILE_CLOSE_STREAM);
|
||||
|
||||
bool isIntersect = RifEclipseOutputFileTools::isExportedFromIntersect(ecl_file);
|
||||
EXPECT_TRUE(isIntersect);
|
||||
|
||||
if (ecl_file_has_kw(ecl_file, porv_kw.data()))
|
||||
{
|
||||
ecl_file_load_all(ecl_file);
|
||||
|
||||
int keywordCount = ecl_file_get_num_named_kw(ecl_file, porv_kw.data());
|
||||
for (int index = 0; index < keywordCount; index++)
|
||||
{
|
||||
auto fileKeyword = ecl_file_iget_named_file_kw(ecl_file, porv_kw.data(), index);
|
||||
|
||||
float porvThreshold = 0.0f;
|
||||
auto actnumFromPorv = ecl_kw_alloc_actnum(ecl_file_kw_get_kw_ptr(fileKeyword), porvThreshold);
|
||||
|
||||
EXPECT_TRUE(actnumFromPorv != nullptr);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user