mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added reading of fracture model active index
Lots of renaming p4#: 20302
This commit is contained in:
@@ -25,12 +25,16 @@
|
||||
#include <QFileInfo>
|
||||
#include "cafProgressInfo.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Constructor
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifEclipseOutputFileTools::RifEclipseOutputFileTools()
|
||||
{
|
||||
m_file = NULL;
|
||||
|
||||
m_globalMatrixActiveCellCounts = 0;;
|
||||
m_globalFractureActiveCellCounts = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +50,7 @@ RifEclipseOutputFileTools::~RifEclipseOutputFileTools()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Open file given by name
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEclipseOutputFileTools::open(const QString& fileName)
|
||||
bool RifEclipseOutputFileTools::open(const QString& fileName, const std::vector<size_t>& matrixActiveCellCounts, const std::vector<size_t>& fractureActiveCellCounts)
|
||||
{
|
||||
// Close current file if any
|
||||
close();
|
||||
@@ -54,6 +58,15 @@ bool RifEclipseOutputFileTools::open(const QString& fileName)
|
||||
m_file = ecl_file_open(fileName.toAscii().data());
|
||||
if (!m_file) return false;
|
||||
|
||||
m_numMatrixActiveCellCounts = matrixActiveCellCounts;
|
||||
m_numFractureActiveCellCount = fractureActiveCellCounts;
|
||||
|
||||
for (size_t i = 0; i < matrixActiveCellCounts.size(); i++)
|
||||
{
|
||||
m_globalMatrixActiveCellCounts += matrixActiveCellCounts[i];
|
||||
m_globalFractureActiveCellCounts += fractureActiveCellCounts[i];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -81,69 +94,6 @@ int RifEclipseOutputFileTools::numOccurrences(const QString& keyword)
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Get keywords found on file given by name.
|
||||
/// If numDataItems != cvf::UNDEFINED_SIZE_T, get keywords with that exact number of data items only.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEclipseOutputFileTools::keywordsWithGivenResultValueCount(QStringList* keywords, size_t expectedResultValueCount, size_t numSteps)
|
||||
{
|
||||
CVF_ASSERT(m_file);
|
||||
CVF_ASSERT(keywords);
|
||||
keywords->clear();
|
||||
|
||||
int numKeywords = ecl_file_get_num_distinct_kw(m_file);
|
||||
|
||||
caf::ProgressInfo info(numKeywords, "Reading Keywords on file");
|
||||
|
||||
for (int i = 0; i < numKeywords; i++)
|
||||
{
|
||||
const char* kw = ecl_file_iget_distinct_kw(m_file , i);
|
||||
int numKeywordOccurrences = ecl_file_get_num_named_kw(m_file, kw);
|
||||
|
||||
if (expectedResultValueCount != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
bool dataTypeSupported = true;
|
||||
int fileResultValueCount = 0;
|
||||
int j;
|
||||
for (j = 0; j < numKeywordOccurrences; j++)
|
||||
{
|
||||
fileResultValueCount += ecl_file_iget_named_size(m_file, kw, j);
|
||||
|
||||
// Check the data type - only float and double are supported
|
||||
ecl_type_enum dataType = ecl_file_iget_named_type(m_file, kw, j);
|
||||
if (dataType != ECL_DOUBLE_TYPE && dataType != ECL_FLOAT_TYPE && dataType != ECL_INT_TYPE )
|
||||
{
|
||||
dataTypeSupported = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dataTypeSupported)
|
||||
{
|
||||
if (numSteps != cvf::UNDEFINED_SIZE_T && numSteps > 0)
|
||||
{
|
||||
fileResultValueCount /= static_cast<int>(numSteps);
|
||||
}
|
||||
|
||||
// Append keyword to the list if it has the given number of values in total
|
||||
if (fileResultValueCount == static_cast<int>(expectedResultValueCount))
|
||||
{
|
||||
keywords->append(QString(kw));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
keywords->append(QString(kw));
|
||||
}
|
||||
|
||||
info.setProgress(i);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Get list of time step texts (dates)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -232,21 +182,44 @@ bool RifEclipseOutputFileTools::timeSteps(QList<QDateTime>* timeSteps)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Get first occurrence of file of given type in given list of filenames, as filename or NULL if not found
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEclipseOutputFileTools::keywordData(const QString& keyword, size_t index, std::vector<double>* values)
|
||||
bool RifEclipseOutputFileTools::keywordData(const QString& keyword, size_t fileKeywordOccurrence,
|
||||
RifReaderInterface::PorosityModelResultType matrixOrFracture,
|
||||
std::vector<double>* values)
|
||||
{
|
||||
CVF_ASSERT(m_file);
|
||||
CVF_ASSERT(values);
|
||||
|
||||
ecl_kw_type* kwData = ecl_file_iget_named_kw(m_file, keyword.toAscii().data(), static_cast<int>(index));
|
||||
if (kwData)
|
||||
size_t gridIndex = fileKeywordOccurrence % m_numMatrixActiveCellCounts.size();
|
||||
|
||||
if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS)
|
||||
{
|
||||
size_t numValues = ecl_kw_get_size(kwData);
|
||||
ecl_kw_type* kwData = ecl_file_iget_named_kw(m_file, keyword.toAscii().data(), static_cast<int>(fileKeywordOccurrence));
|
||||
if (kwData)
|
||||
{
|
||||
size_t numValues = ecl_kw_get_size(kwData);
|
||||
|
||||
std::vector<double> doubleData;
|
||||
doubleData.resize(numValues);
|
||||
std::vector<double> doubleData;
|
||||
doubleData.resize(numValues);
|
||||
|
||||
ecl_kw_get_data_as_double(kwData, doubleData.data());
|
||||
values->insert(values->end(), doubleData.begin(), doubleData.end());
|
||||
ecl_kw_get_data_as_double(kwData, doubleData.data());
|
||||
values->insert(values->end(), doubleData.begin(), doubleData.begin() + m_numMatrixActiveCellCounts[gridIndex]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ecl_kw_type* kwData = ecl_file_iget_named_kw(m_file, keyword.toAscii().data(), static_cast<int>(fileKeywordOccurrence));
|
||||
if (kwData)
|
||||
{
|
||||
size_t numValues = ecl_kw_get_size(kwData);
|
||||
CVF_ASSERT(numValues == m_numMatrixActiveCellCounts[gridIndex] + m_numFractureActiveCellCount[gridIndex]);
|
||||
|
||||
std::vector<double> doubleData;
|
||||
doubleData.resize(numValues);
|
||||
|
||||
ecl_kw_get_data_as_double(kwData, doubleData.data());
|
||||
|
||||
values->insert(values->end(), doubleData.begin() + m_numMatrixActiveCellCounts[gridIndex], doubleData.end());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -328,3 +301,65 @@ ecl_file_type* RifEclipseOutputFileTools::filePointer()
|
||||
{
|
||||
return m_file;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEclipseOutputFileTools::validKeywords(QStringList* keywords, RifReaderInterface::PorosityModelResultType matrixOrFracture)
|
||||
{
|
||||
if (m_globalMatrixActiveCellCounts == 0) return true;
|
||||
|
||||
CVF_ASSERT(m_file);
|
||||
CVF_ASSERT(keywords);
|
||||
|
||||
if (!keywords) return false;
|
||||
keywords->clear();
|
||||
|
||||
int numKeywords = ecl_file_get_num_distinct_kw(m_file);
|
||||
|
||||
caf::ProgressInfo info(numKeywords, "Reading Keywords on file");
|
||||
|
||||
for (int i = 0; i < numKeywords; i++)
|
||||
{
|
||||
const char* kw = ecl_file_iget_distinct_kw(m_file , i);
|
||||
int numKeywordOccurrences = ecl_file_get_num_named_kw(m_file, kw);
|
||||
bool validData = true;
|
||||
size_t fileResultValueCount = 0;
|
||||
for (int j = 0; j < numKeywordOccurrences; j++)
|
||||
{
|
||||
fileResultValueCount += ecl_file_iget_named_size(m_file, kw, j);
|
||||
|
||||
ecl_type_enum dataType = ecl_file_iget_named_type(m_file, kw, j);
|
||||
if (dataType != ECL_DOUBLE_TYPE && dataType != ECL_FLOAT_TYPE && dataType != ECL_INT_TYPE )
|
||||
{
|
||||
validData = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (validData)
|
||||
{
|
||||
// Only report valid fracture results when total result value count equals matrix and fracture
|
||||
if (matrixOrFracture == RifReaderInterface::FRACTURE_RESULTS)
|
||||
{
|
||||
size_t rest = fileResultValueCount % (m_globalMatrixActiveCellCounts + m_globalFractureActiveCellCounts);
|
||||
if (rest == 0)
|
||||
{
|
||||
keywords->append(QString(kw));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t rest = fileResultValueCount % (m_globalMatrixActiveCellCounts);
|
||||
if (rest == 0)
|
||||
{
|
||||
keywords->append(QString(kw));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
info.setProgress(i);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user