#3119 detect grid unit. Read unit system from one of three available sources

This commit is contained in:
Bjørn Erik Jensen 2018-08-15 14:47:32 +02:00
parent 59f9d189e5
commit 2e78bddaf6
2 changed files with 37 additions and 20 deletions

View File

@ -414,7 +414,7 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigEclipseCaseData* e
// Build results meta data // Build results meta data
progInfo.setProgressDescription("Reading Result index"); progInfo.setProgressDescription("Reading Result index");
progInfo.setNextProgressIncrement(25); progInfo.setNextProgressIncrement(25);
buildMetaData(); buildMetaData(mainEclGrid);
progInfo.incrementProgress(); progInfo.incrementProgress();
if (isNNCsEnabled()) if (isNNCsEnabled())
@ -810,7 +810,7 @@ bool RifReaderEclipseOutput::readActiveCellInfo()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Build meta data - get states and results info /// Build meta data - get states and results info
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::buildMetaData() void RifReaderEclipseOutput::buildMetaData(ecl_grid_type* grid)
{ {
CVF_ASSERT(m_eclipseCase); CVF_ASSERT(m_eclipseCase);
CVF_ASSERT(m_filesWithSameBaseName.size() > 0); CVF_ASSERT(m_filesWithSameBaseName.size() > 0);
@ -863,28 +863,45 @@ void RifReaderEclipseOutput::buildMetaData()
fractureModelResults->setTimeStepInfos(resIndex, timeStepInfos); fractureModelResults->setTimeStepInfos(resIndex, timeStepInfos);
} }
} }
// Default units type is METRIC
RiaEclipseUnitTools::UnitSystem unitsType = RiaEclipseUnitTools::UNITS_METRIC;
{
int unitsTypeValue = m_dynamicResultsAccess->readUnitsType();
if (unitsTypeValue == 2)
{
unitsType = RiaEclipseUnitTools::UNITS_FIELD;
}
else if (unitsTypeValue == 3)
{
unitsType = RiaEclipseUnitTools::UNITS_LAB;
}
}
m_eclipseCase->setUnitsType(unitsType);
} }
progInfo.incrementProgress(); progInfo.incrementProgress();
openInitFile(); openInitFile();
// Unit system
{
// Default units type is METRIC
RiaEclipseUnitTools::UnitSystem unitsType = RiaEclipseUnitTools::UNITS_METRIC;
int unitsTypeValue;
if (m_dynamicResultsAccess.notNull())
{
unitsTypeValue = m_dynamicResultsAccess->readUnitsType();
}
else
{
if (m_ecl_init_file)
{
unitsTypeValue = RifEclipseOutputFileTools::readUnitsType(m_ecl_init_file);
}
else
{
unitsTypeValue = ecl_grid_get_unit_system(grid);
}
}
if (unitsTypeValue == 2)
{
unitsType = RiaEclipseUnitTools::UNITS_FIELD;
}
else if (unitsTypeValue == 3)
{
unitsType = RiaEclipseUnitTools::UNITS_LAB;
}
m_eclipseCase->setUnitsType(unitsType);
}
progInfo.incrementProgress(); progInfo.incrementProgress();
if (m_ecl_init_file) if (m_ecl_init_file)

View File

@ -72,7 +72,7 @@ public:
private: private:
bool readActiveCellInfo(); bool readActiveCellInfo();
void buildMetaData(); void buildMetaData(ecl_grid_type* grid);
void readWellCells(const ecl_grid_type* mainEclGrid, bool importCompleteMswData); void readWellCells(const ecl_grid_type* mainEclGrid, bool importCompleteMswData);
std::string ertGridName( size_t gridNr ); std::string ertGridName( size_t gridNr );