Added reading of active cell data from EGRID file directly

p4#: 20640
This commit is contained in:
Magne Sjaastad 2013-02-27 11:27:02 +01:00
parent ad082254af
commit df281ccb2b
5 changed files with 169 additions and 16 deletions

View File

@ -172,6 +172,28 @@ bool RifEclipseOutputFileTools::keywordData(ecl_file_type* ecl_file, const QStri
return false; return false;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifEclipseOutputFileTools::keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector<int>* values)
{
ecl_kw_type* kwData = ecl_file_iget_named_kw(ecl_file, keyword.toAscii().data(), static_cast<int>(fileKeywordOccurrence));
if (kwData)
{
size_t numValues = ecl_kw_get_size(kwData);
std::vector<int> integerData;
integerData.resize(numValues);
ecl_kw_get_memcpy_int_data(kwData, integerData.data());
values->insert(values->end(), integerData.begin(), integerData.end());
return true;
}
return false;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Get first occurrence of file of given type in given list of filenames, as filename or NULL if not found /// Get first occurrence of file of given type in given list of filenames, as filename or NULL if not found

View File

@ -45,6 +45,7 @@ public:
static void findKeywordsAndDataItemCounts(ecl_file_type* ecl_file, QStringList* keywords, std::vector<size_t>* keywordDataItemCounts); static void findKeywordsAndDataItemCounts(ecl_file_type* ecl_file, QStringList* keywords, std::vector<size_t>* keywordDataItemCounts);
static bool keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector<double>* values); static bool keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector<double>* values);
static bool keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector<int>* values);
// static void timeStepsText(ecl_file_type* ecl_file, QStringList* timeSteps); // static void timeStepsText(ecl_file_type* ecl_file, QStringList* timeSteps);
static void timeSteps(ecl_file_type* ecl_file, QList<QDateTime>* timeSteps, bool* detectedFractionOfDay = NULL); static void timeSteps(ecl_file_type* ecl_file, QList<QDateTime>* timeSteps, bool* detectedFractionOfDay = NULL);

View File

@ -32,6 +32,8 @@
#include "ecl_grid.h" #include "ecl_grid.h"
#include "well_state.h" #include "well_state.h"
#include "ecl_kw_magic.h"
#include "cafProgressInfo.h" #include "cafProgressInfo.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -189,6 +191,8 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RifReaderEclipseOutput::RifReaderEclipseOutput() RifReaderEclipseOutput::RifReaderEclipseOutput()
{ {
m_ecl_file = NULL;
ground(); ground();
} }
@ -216,7 +220,12 @@ void RifReaderEclipseOutput::ground()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::close() void RifReaderEclipseOutput::close()
{ {
if (m_ecl_file)
{
ecl_file_close(m_ecl_file);
}
m_ecl_file = NULL; m_ecl_file = NULL;
m_dynamicResultsAccess = NULL; m_dynamicResultsAccess = NULL;
ground(); ground();
@ -383,6 +392,116 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigEclipseCase* eclip
return true; return true;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::openWithoutReadingData(const QString& fileName, RigEclipseCase* eclipseCase)
{
CVF_ASSERT(eclipseCase);
caf::ProgressInfo progInfo(100, "");
close();
// Get set of files
QStringList fileSet;
if (!RifEclipseOutputFileTools::fileSet(fileName, &fileSet)) return false;
// Keep the set of files of interest
m_fileSet = fileSet;
m_reservoir = eclipseCase;
eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this);
eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this);
progInfo.setNextProgressIncrement(50);
progInfo.setProgressDescription("Reading active cell information");
readActiveCellInfo(eclipseCase);
progInfo.incrementProgress();
progInfo.setNextProgressIncrement(50);
progInfo.setProgressDescription("Reading meta data");
// Build results meta data
if (!buildMetaData(eclipseCase)) return false;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::readActiveCellInfo(RigEclipseCase* eclipseCase)
{
CVF_ASSERT(eclipseCase);
QString egridFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_EGRID_FILE);
if (egridFileName.size() > 0)
{
ecl_file_type* ecl_file = ecl_file_open(egridFileName.toAscii().data());
if (!ecl_file) return false;
int actnumKeywordCount = ecl_file_get_num_named_kw(ecl_file, ACTNUM_KW);
if (actnumKeywordCount > 0)
{
std::vector<std::vector<int> > actnumValuesPerGrid;
actnumValuesPerGrid.resize(actnumKeywordCount);
size_t globalCellCount = 0;
for (size_t gridIdx = 0; gridIdx < actnumKeywordCount; gridIdx++)
{
RifEclipseOutputFileTools::keywordData(ecl_file, ACTNUM_KW, gridIdx, &actnumValuesPerGrid[gridIdx]);
globalCellCount += actnumValuesPerGrid[gridIdx].size();
}
RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo();
activeCellInfo->setGlobalCellCount(globalCellCount);
activeCellInfo->setGridCount(actnumKeywordCount);
size_t cellIdx = 0;
for (size_t gridIdx = 0; gridIdx < actnumKeywordCount; gridIdx++)
{
size_t activeMatrixIndex = 0;
size_t activeFractureIndex = 0;
std::vector<int>& actnumValues = actnumValuesPerGrid[gridIdx];
for (size_t i = 0; i < actnumValues.size(); i++)
{
if (actnumValues[i] == 1 || actnumValues[i] == 3)
{
activeCellInfo->setActiveIndexInMatrixModel(cellIdx, activeMatrixIndex++);
}
if (actnumValues[i] == 2 || actnumValues[i] == 3)
{
activeCellInfo->setActiveIndexInFractureModel(cellIdx, activeFractureIndex++);
}
cellIdx++;
}
activeCellInfo->setGridActiveCellCounts(gridIdx, activeMatrixIndex, activeFractureIndex);
}
activeCellInfo->computeDerivedData();
}
ecl_file_close(ecl_file);
return true;
}
return false;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Build meta data - get states and results info /// Build meta data - get states and results info
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -402,6 +521,7 @@ bool RifReaderEclipseOutput::buildMetaData(RigEclipseCase* eclipseCase)
return false; return false;
} }
progInfo.incrementProgress(); progInfo.incrementProgress();
RigReservoirCellResults* matrixModelResults = m_reservoir->results(RifReaderInterface::MATRIX_RESULTS); RigReservoirCellResults* matrixModelResults = m_reservoir->results(RifReaderInterface::MATRIX_RESULTS);
@ -778,6 +898,8 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL
QString keyword = keywords[i]; QString keyword = keywords[i];
size_t keywordDataCount = keywordDataItemCounts[i]; size_t keywordDataCount = keywordDataItemCounts[i];
if (activeCellInfo->globalMatrixModelActiveCellCount() > 0)
{
size_t timeStepsMatrix = keywordDataItemCounts[i] / activeCellInfo->globalMatrixModelActiveCellCount(); size_t timeStepsMatrix = keywordDataItemCounts[i] / activeCellInfo->globalMatrixModelActiveCellCount();
size_t timeStepsMatrixRest = keywordDataItemCounts[i] % activeCellInfo->globalMatrixModelActiveCellCount(); size_t timeStepsMatrixRest = keywordDataItemCounts[i] % activeCellInfo->globalMatrixModelActiveCellCount();
@ -802,10 +924,16 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL
} }
} }
} }
else
{
keywordsWithCorrectNumberOfDataItems.push_back(keywords[i]);
}
}
return keywordsWithCorrectNumberOfDataItems; return keywordsWithCorrectNumberOfDataItems;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -44,6 +44,7 @@ public:
virtual ~RifReaderEclipseOutput(); virtual ~RifReaderEclipseOutput();
bool open(const QString& fileName, RigEclipseCase* eclipseCase); bool open(const QString& fileName, RigEclipseCase* eclipseCase);
virtual bool openWithoutReadingData(const QString& fileName, RigEclipseCase* eclipseCase);
void close(); void close();
bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values); bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values);
@ -53,6 +54,7 @@ public:
private: private:
void ground(); void ground();
bool readActiveCellInfo(RigEclipseCase* eclipseCase);
bool buildMetaData(RigEclipseCase* eclipseCase); bool buildMetaData(RigEclipseCase* eclipseCase);
void readWellCells(RigEclipseCase* eclipseCase); void readWellCells(RigEclipseCase* eclipseCase);

View File

@ -47,9 +47,9 @@ public:
virtual ~RifReaderInterface() {} virtual ~RifReaderInterface() {}
virtual bool open(const QString& fileName, RigEclipseCase* eclipseCase) = 0; virtual bool open(const QString& fileName, RigEclipseCase* eclipseCase) = 0;
virtual bool openWithoutReadingData(const QString& fileName, RigEclipseCase* eclipseCase) { return true; };
virtual void close() = 0; virtual void close() = 0;
virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values) = 0; virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values) = 0;
virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values) = 0; virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values) = 0;
}; };