#1356 Do not check active cell count when reading result names

This commit is contained in:
Magne Sjaastad 2017-03-24 11:17:12 +01:00
parent c4cd1972c4
commit 34d9b1358e
5 changed files with 40 additions and 51 deletions

View File

@ -54,8 +54,7 @@ bool RifHdf5Reader::dynamicResult(const QString& result, size_t stepIndex, std::
{ {
H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately
std::string fileName = m_fileName.toStdString(); // her ligger trøbbel mht Unicode or det smalt i H5File med direkte bruk av c_str() std::string fileName = m_fileName.toStdString(); // her ligger tr<74>bbel mht Unicode or det smalt i H5File med direkte bruk av c_str(
H5::H5File file(fileName.c_str(), H5F_ACC_RDONLY); H5::H5File file(fileName.c_str(), H5F_ACC_RDONLY);
std::string groupName = "/Timestep_00001/GridFunctions/GridPart_00000/GridFunction_00002"; std::string groupName = "/Timestep_00001/GridFunctions/GridPart_00000/GridFunction_00002";
@ -98,7 +97,7 @@ QStringList RifHdf5Reader::propertyNames() const
{ {
QStringList propNames; QStringList propNames;
std::string str = m_fileName.toStdString(); // her ligger trøbbel mht Unicode or det smalt i H5File med direkte bruk av c_str() std::string str = m_fileName.toStdString(); // her ligger tr<EFBFBD>bbel mht Unicode or det smalt i H5File med direkte bruk av c_str()
H5::H5File file(str.c_str(), H5F_ACC_RDONLY); H5::H5File file(str.c_str(), H5F_ACC_RDONLY);
@ -114,18 +113,6 @@ QStringList RifHdf5Reader::propertyNames() const
return propNames; return propNames;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifHdf5Reader::resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts)
{
*resultNames = propertyNames();
for (size_t i = 0; i < propertyNames().size(); i++)
{
resultDataItemCounts->push_back(16336);
}
}

View File

@ -35,17 +35,9 @@ public:
explicit RifHdf5Reader(const QString& fileName); explicit RifHdf5Reader(const QString& fileName);
virtual ~RifHdf5Reader(); virtual ~RifHdf5Reader();
bool dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values) const; std::vector<QDateTime> timeSteps() const override;
virtual QStringList propertyNames() const override;
bool dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values) const override;
std::vector<QDateTime> timeSteps() const;
virtual QStringList propertyNames() const override;
virtual void resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts) override;
private: private:
int getIntAttribute(H5::H5File file, std::string groupName, std::string attributeName) const; int getIntAttribute(H5::H5File file, std::string groupName, std::string attributeName) const;
@ -56,7 +48,6 @@ private:
std::vector<std::string> getResultNames(H5::H5File file, std::string baseGroupName) const; std::vector<std::string> getResultNames(H5::H5File file, std::string baseGroupName) const;
void getElementResultValues(H5::H5File file, std::string groupName, std::vector<double>* resultValues) const; void getElementResultValues(H5::H5File file, std::string groupName, std::vector<double>* resultValues) const;
private: private:
QString m_fileName; QString m_fileName;
}; };

View File

@ -34,6 +34,5 @@ class RifHdf5ReaderInterface
public: public:
virtual std::vector<QDateTime> timeSteps() const = 0; virtual std::vector<QDateTime> timeSteps() const = 0;
virtual QStringList propertyNames() const = 0; virtual QStringList propertyNames() const = 0;
virtual void resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts) = 0;
virtual bool dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values) const = 0; virtual bool dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values) const = 0;
}; };

View File

@ -491,31 +491,20 @@ void RifReaderEclipseOutput::setHdf5FileName(const QString& fileName)
{ {
reportNumbers = m_dynamicResultsAccess->reportNumbers(); reportNumbers = m_dynamicResultsAccess->reportNumbers();
} }
else
QStringList resultNames;
std::vector<size_t> resultNamesDataItemCounts;
myReader->resultNames(&resultNames, &resultNamesDataItemCounts);
if (resultNames.size() != static_cast<int>(resultNamesDataItemCounts.size()))
{ {
RiaLogging::error("HDF: Result name vectors and result name data item count does not match"); for (size_t i = 0; i < m_timeSteps.size(); i++)
{
return; reportNumbers.push_back(static_cast<int>(i));
}
} }
size_t activeCellCount = 0; QStringList resultNames = myReader->propertyNames();
matrixModelResults->activeCellInfo()->gridActiveCellCounts(0, activeCellCount);
for (int i = 0; i < resultNames.size(); ++i) for (int i = 0; i < resultNames.size(); ++i)
{ {
if (activeCellCount != resultNamesDataItemCounts[i]) size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, resultNames[i], false);
{ matrixModelResults->setTimeStepDates(resIndex, m_timeSteps, reportNumbers);
RiaLogging::error("HDF: Number of active cells does not match");
}
else
{
size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, resultNames[i], false);
matrixModelResults->setTimeStepDates(resIndex, m_timeSteps, reportNumbers);
}
} }
m_hdfReaderInterface = std::move(myReader); m_hdfReaderInterface = std::move(myReader);
@ -941,10 +930,33 @@ bool RifReaderEclipseOutput::dynamicResult(const QString& result, PorosityModelR
#ifdef USE_HDF5 #ifdef USE_HDF5
if (m_hdfReaderInterface) if (m_hdfReaderInterface)
{ {
if (m_hdfReaderInterface->dynamicResult(result, stepIndex, values)) if (m_eclipseCase->mainGrid()->gridCount() == 0)
{ {
return true; RiaLogging::error("No grids available");
return false;
} }
size_t activeCellCount = cvf::UNDEFINED_SIZE_T;
{
RigActiveCellInfo* fracActCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS);
fracActCellInfo->gridActiveCellCounts(0, activeCellCount);
}
bool readCellResultOk = m_hdfReaderInterface->dynamicResult(result, stepIndex, values);
if (activeCellCount != values->size())
{
for (size_t i=0; i < values->size(); i++)
{
values->at(i) = HUGE_VAL;
}
RiaLogging::error("No grids available");
return false;
}
return readCellResultOk;
} }
#endif #endif

View File

@ -472,7 +472,7 @@ TEST(RigReservoirTest, WellTest)
// Location of test dataset received from Håkon Høgstøl in July 2011 with 10k active cells // Location of test dataset received from Håkon Høgstøl in July 2011 with 10k active cells
#ifdef WIN32 #ifdef WIN32
QString filename("d:/Models/Statoil/soursim/PKMUNK_NOV_TEST_SS.GRID"); QString filename("d:/Models/Statoil/soursim/PKMUNK_NOV_TEST_SS.GRID");
QString sourSim("d:/Models/Statoil/soursim/result.sourres"); QString sourSim("d:/Models/Statoil/soursim/result.sourres.00001");
#else #else
QString filename("/mnt/hgfs/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.EGRID"); QString filename("/mnt/hgfs/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.EGRID");
QString sourSim("d:/Models/Statoil/soursim/result.sourres"); QString sourSim("d:/Models/Statoil/soursim/result.sourres");
@ -482,4 +482,4 @@ TEST(RigReservoirTest, WellTest)
EXPECT_TRUE(result); EXPECT_TRUE(result);
readerInterfaceEcl->setHdf5FileName(sourSim); readerInterfaceEcl->setHdf5FileName(sourSim);
} }