mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Updated ERT to 315ceeee250808ea6a6530233dd5125f9f76f06c
Support of reading LGR dimensions Close file handles between access to files, keep ERT file-related cache to speed up reading of many files multiple times p4#: 21477
This commit is contained in:
@@ -308,14 +308,27 @@ void RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(ecl_file_type* ecl
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseOutputFileTools::readGridDimensions(const QString& gridFileName, std::vector< std::vector<int> >& gridDimensions)
|
||||
{
|
||||
int gridDims[3];
|
||||
ecl_grid_type * grid = ecl_grid_alloc(gridFileName.toAscii().data()); // bootstrap ecl_grid instance
|
||||
stringlist_type * lgr_names = ecl_grid_alloc_lgr_name_list( grid ); // get a list of all the lgr names.
|
||||
|
||||
bool ret = ecl_grid_file_dims(gridFileName.toAscii().data(), NULL, gridDims);
|
||||
if (ret)
|
||||
//printf("grid:%s has %d a total of %d lgr's \n", grid_filename , stringlist_get_size( lgr_names ));
|
||||
for (int lgr_nr = 0; lgr_nr < stringlist_get_size( lgr_names); lgr_nr++)
|
||||
{
|
||||
gridDimensions.resize(1);
|
||||
gridDimensions[0].push_back(gridDims[0]);
|
||||
gridDimensions[0].push_back(gridDims[1]);
|
||||
gridDimensions[0].push_back(gridDims[2]);
|
||||
ecl_grid_type * lgr_grid = ecl_grid_get_lgr( grid , stringlist_iget( lgr_names , lgr_nr )); // get the ecl_grid instance of the lgr - by name.
|
||||
|
||||
int nx,ny,nz,active_size;
|
||||
ecl_grid_get_dims( lgr_grid , &nx , &ny , &nz , &active_size); // get some size info from this lgr.
|
||||
|
||||
std::vector<int> values;
|
||||
values.push_back(nx);
|
||||
values.push_back(ny);
|
||||
values.push_back(nz);
|
||||
values.push_back(active_size);
|
||||
|
||||
gridDimensions.push_back(values);
|
||||
}
|
||||
|
||||
ecl_grid_free( grid );
|
||||
stringlist_free( lgr_names );
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,17 @@ RifEclipseRestartFilesetAccess::RifEclipseRestartFilesetAccess()
|
||||
RifEclipseRestartFilesetAccess::~RifEclipseRestartFilesetAccess()
|
||||
{
|
||||
close();
|
||||
|
||||
for (size_t i = 0; i < m_ecl_files.size(); i++)
|
||||
{
|
||||
if (m_ecl_files[i])
|
||||
{
|
||||
ecl_file_close(m_ecl_files[i]);
|
||||
}
|
||||
|
||||
m_ecl_files[i] = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -84,15 +95,6 @@ void RifEclipseRestartFilesetAccess::setRestartFiles(const QStringList& fileSet)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseRestartFilesetAccess::close()
|
||||
{
|
||||
for (size_t i = 0; i < m_ecl_files.size(); i++)
|
||||
{
|
||||
if (m_ecl_files[i])
|
||||
{
|
||||
ecl_file_close(m_ecl_files[i]);
|
||||
}
|
||||
|
||||
m_ecl_files[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -232,7 +234,7 @@ void RifEclipseRestartFilesetAccess::openTimeStep(size_t timeStep)
|
||||
if (m_ecl_files[timeStep] == NULL)
|
||||
{
|
||||
int index = static_cast<int>(timeStep);
|
||||
ecl_file_type* ecl_file = ecl_file_open(m_fileNames[index].toAscii().data());
|
||||
ecl_file_type* ecl_file = ecl_file_open(m_fileNames[index].toAscii().data(), ECL_FILE_CLOSE_STREAM);
|
||||
|
||||
m_ecl_files[timeStep] = ecl_file;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,10 @@ RifEclipseUnifiedRestartFileAccess::RifEclipseUnifiedRestartFileAccess()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifEclipseUnifiedRestartFileAccess::~RifEclipseUnifiedRestartFileAccess()
|
||||
{
|
||||
close();
|
||||
if (m_ecl_file)
|
||||
{
|
||||
ecl_file_close(m_ecl_file);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -56,7 +59,7 @@ bool RifEclipseUnifiedRestartFileAccess::openFile()
|
||||
{
|
||||
if (!m_ecl_file)
|
||||
{
|
||||
m_ecl_file = ecl_file_open(m_filename.toAscii().data());
|
||||
m_ecl_file = ecl_file_open(m_filename.toAscii().data(), ECL_FILE_CLOSE_STREAM);
|
||||
}
|
||||
|
||||
if (!m_ecl_file) return false;
|
||||
@@ -69,12 +72,6 @@ bool RifEclipseUnifiedRestartFileAccess::openFile()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseUnifiedRestartFileAccess::close()
|
||||
{
|
||||
if (m_ecl_file)
|
||||
{
|
||||
ecl_file_close(m_ecl_file);
|
||||
}
|
||||
|
||||
m_ecl_file = NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -208,14 +208,7 @@ RifReaderEclipseOutput::RifReaderEclipseOutput()
|
||||
RifReaderEclipseOutput::~RifReaderEclipseOutput()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Close interface (for now, no files are kept open after calling methods, so just clear members)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifReaderEclipseOutput::close()
|
||||
{
|
||||
if (m_ecl_init_file)
|
||||
{
|
||||
ecl_file_close(m_ecl_init_file);
|
||||
@@ -226,6 +219,15 @@ void RifReaderEclipseOutput::close()
|
||||
{
|
||||
m_dynamicResultsAccess->close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Close interface (for now, no files are kept open after calling methods, so just clear members)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifReaderEclipseOutput::close()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -442,7 +444,7 @@ bool RifReaderEclipseOutput::readActiveCellInfo()
|
||||
QString egridFileName = RifEclipseOutputFileTools::firstFileNameOfType(m_filesWithSameBaseName, ECL_EGRID_FILE);
|
||||
if (egridFileName.size() > 0)
|
||||
{
|
||||
ecl_file_type* ecl_file = ecl_file_open(egridFileName.toAscii().data());
|
||||
ecl_file_type* ecl_file = ecl_file_open(egridFileName.toAscii().data(), ECL_FILE_CLOSE_STREAM);
|
||||
if (!ecl_file) return false;
|
||||
|
||||
int actnumKeywordCount = ecl_file_get_num_named_kw(ecl_file, ACTNUM_KW);
|
||||
@@ -1010,7 +1012,7 @@ void RifReaderEclipseOutput::openInitFile()
|
||||
QString initFileName = RifEclipseOutputFileTools::firstFileNameOfType(m_filesWithSameBaseName, ECL_INIT_FILE);
|
||||
if (initFileName.size() > 0)
|
||||
{
|
||||
m_ecl_init_file = ecl_file_open(initFileName.toAscii().data());
|
||||
m_ecl_init_file = ecl_file_open(initFileName.toAscii().data(), ECL_FILE_CLOSE_STREAM);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user