#2097 Reservoir Phase Detection : Find available phases from result files

This commit is contained in:
Magne Sjaastad 2017-11-10 09:43:51 +01:00
parent f8a2250f3c
commit 5db08c7b76
13 changed files with 160 additions and 0 deletions

View File

@ -102,5 +102,11 @@ namespace RiaDefines
double minimumDefaultValuePlot();
double maximumDefaultValuePlot();
enum PhaseType {
OIL_PHASE,
GAS_PHASE,
WATER_PHASE
};
};

View File

@ -383,6 +383,40 @@ QString RifEclipseOutputFileTools::createIndexFileName(const QString& resultFile
return indexFileName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RiaDefines::PhaseType> RifEclipseOutputFileTools::findAvailablePhases(ecl_file_type* ecl_file)
{
std::set<RiaDefines::PhaseType> phaseTypes;
if (ecl_file)
{
const ecl_kw_type* intehead = ecl_file_iget_named_kw(ecl_file, INTEHEAD_KW, 0);
if (intehead)
{
int phases = ecl_kw_iget_int(intehead, INTEHEAD_PHASE_INDEX);
if (phases & ECL_OIL_PHASE)
{
phaseTypes.insert(RiaDefines::OIL_PHASE);
}
if (phases & ECL_GAS_PHASE)
{
phaseTypes.insert(RiaDefines::GAS_PHASE);
}
if (phases & ECL_WATER_PHASE)
{
phaseTypes.insert(RiaDefines::WATER_PHASE);
}
}
}
return phaseTypes;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -69,6 +69,8 @@ public:
static QString createIndexFileName(const QString& resultFileName);
static std::set<RiaDefines::PhaseType> findAvailablePhases(ecl_file_type* ecl_file);
private:
static void createReportStepsMetaData(std::vector<ecl_file_type*> ecl_files, std::vector<RifRestartReportStep>* reportSteps);
};

View File

@ -108,4 +108,6 @@ public:
virtual void readWellData(well_info_type * well_info, bool importCompleteMswData) = 0;
virtual int readUnitsType() = 0;
virtual std::set<RiaDefines::PhaseType> availablePhases() const = 0;
};

View File

@ -294,6 +294,13 @@ void RifEclipseRestartFilesetAccess::openTimeStep(size_t timeStep)
ecl_file_type* ecl_file = ecl_file_open(m_fileNames[index].toAscii().data(), ECL_FILE_CLOSE_STREAM);
m_ecl_files[timeStep] = ecl_file;
if (ecl_file)
{
auto phases = RifEclipseOutputFileTools::findAvailablePhases(ecl_file);
m_availablePhases.insert(phases.begin(), phases.end());
}
}
}
@ -313,6 +320,14 @@ int RifEclipseRestartFilesetAccess::readUnitsType()
return RifEclipseOutputFileTools::readUnitsType(ecl_file);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RiaDefines::PhaseType> RifEclipseRestartFilesetAccess::availablePhases() const
{
return m_availablePhases;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -54,6 +54,8 @@ public:
virtual void readWellData(well_info_type* well_info, bool importCompleteMswData);
virtual int readUnitsType();
virtual std::set<RiaDefines::PhaseType> availablePhases() const override;
private:
void openTimeStep(size_t timeStep);
@ -63,4 +65,5 @@ private:
std::vector<double> m_daysSinceSimulationStart;
std::vector< ecl_file_type* > m_ecl_files;
std::set<RiaDefines::PhaseType> m_availablePhases;
};

View File

@ -128,8 +128,11 @@ bool RifEclipseUnifiedRestartFileAccess::openFile()
}
}
if (!m_ecl_file) return false;
m_availablePhases = RifEclipseOutputFileTools::findAvailablePhases(m_ecl_file);
return true;
}
@ -346,6 +349,14 @@ int RifEclipseUnifiedRestartFileAccess::readUnitsType()
return RifEclipseOutputFileTools::readUnitsType(m_ecl_file);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RiaDefines::PhaseType> RifEclipseUnifiedRestartFileAccess::availablePhases() const
{
return m_availablePhases;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -57,6 +57,8 @@ public:
virtual void readWellData(well_info_type * well_info, bool importCompleteMswData);
virtual int readUnitsType();
virtual std::set<RiaDefines::PhaseType> availablePhases() const override;
private:
bool openFile();
bool useResultIndexFile() const;
@ -69,4 +71,6 @@ private:
std::vector<QDateTime> m_timeSteps;
std::vector<double> m_daysSinceSimulationStart;
std::vector<int> m_reportNr;
std::set<RiaDefines::PhaseType> m_availablePhases;
};

View File

@ -2076,6 +2076,19 @@ void RifReaderEclipseOutput::transferCoarseningInfo(const ecl_grid_type* eclGrid
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RiaDefines::PhaseType> RifReaderEclipseOutput::availablePhases() const
{
if (m_dynamicResultsAccess.notNull())
{
return m_dynamicResultsAccess->availablePhases();
}
return std::set<RiaDefines::PhaseType>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -68,6 +68,8 @@ public:
static bool transferGeometry(const ecl_grid_type* mainEclGrid, RigEclipseCaseData* eclipseCase);
static void transferCoarseningInfo(const ecl_grid_type* eclGrid, RigGridBase* grid);
virtual std::set<RiaDefines::PhaseType> availablePhases() const override;
private:
bool readActiveCellInfo();
void buildMetaData();

View File

@ -64,6 +64,14 @@ void RifReaderInterface::setTimeStepFilter(const std::vector<size_t>& fileTimeSt
m_fileTimeStepIndices = fileTimeStepIndices;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RiaDefines::PhaseType> RifReaderInterface::availablePhases() const
{
return std::set<RiaDefines::PhaseType>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -20,6 +20,7 @@
#pragma once
#include "RiaDefines.h"
#include "RiaPorosityModel.h"
#include "cvfBase.h"
@ -31,6 +32,7 @@
#include <QStringList>
#include <vector>
#include <set>
class RigEclipseCaseData;
@ -63,6 +65,8 @@ public:
void setTimeStepFilter(const std::vector<size_t>& fileTimeStepIndices);
virtual std::set<RiaDefines::PhaseType> availablePhases() const;
protected:
bool isTimeStepIncludedByFilter(size_t timeStepIndex) const;
size_t timeStepIndexOnFile(size_t timeStepIndex) const;

View File

@ -23,6 +23,7 @@
#include "RigEclipseCaseData.h"
#include <ert/ecl/ecl_file.h>
#include "ert/ecl/ecl_kw_magic.h"
#include "RifReaderEclipseOutput.h"
#include "RifEclipseOutputFileTools.h"
@ -483,3 +484,58 @@ TEST(DISABLED_RigReservoirTest, WellTest)
readerInterfaceEcl->setHdf5FileName(sourSim);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(RigReservoirTest, TestForPhase)
{
/*
cvf::ref<RifReaderEclipseOutput> readerInterfaceEcl = new RifReaderEclipseOutput;
cvf::ref<RigEclipseCaseData> reservoir = new RigEclipseCaseData(nullptr);
// Location of test dataset received from Håkon Høgstøl in July 2011 with 10k active cells
#ifdef WIN32
QString filename("d:/Models/Statoil/soursim/PKMUNK_NOV_TEST_SS.GRID");
QString sourSim("d:/Models/Statoil/soursim/result.sourres.00001");
#else
QString filename("/mnt/hgfs/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.EGRID");
QString sourSim("d:/Models/Statoil/soursim/result.sourres");
#endif
bool result = readerInterfaceEcl->open(filename, reservoir.p());
EXPECT_TRUE(result);
readerInterfaceEcl->setHdf5FileName(sourSim);
*/
std::string filename = "d:/Models/Statoil/troll_MSW/T07-4A-W2012-16-F3.UNRST";
//std::string filename = "d:/Models/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.UNRST";
//std::string filename = "d:/Models/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.INIT";
//std::string filename = "d:/Models/Statoil/TEST10K_FLT_LGR_NNC_TSTEP/TEST10K_FLT_LGR_NNC_TSTEP.UNRST";
//std::string filename = "d:/Models/Statoil/gas_case_only_water/TEST_GASWATER.X0000";
ecl_file_type * f = ecl_file_open(filename.data(), ECL_FILE_CLOSE_STREAM);
const ecl_kw_type * intehead = ecl_file_iget_named_kw(f, INTEHEAD_KW, 0);
int phases = ecl_kw_iget_int(intehead, INTEHEAD_PHASE_INDEX);
if (phases & ECL_OIL_PHASE)
{
qDebug() << "oil";
}
if (phases & ECL_GAS_PHASE)
{
qDebug() << "gas";
}
if (phases & ECL_WATER_PHASE)
{
qDebug() << "water";
}
ecl_file_close(f);
}