Add readGridDimensions

This commit is contained in:
Magne Sjaastad
2026-02-13 14:35:52 +01:00
parent 10e8d9e39a
commit 472d7fa296
2 changed files with 35 additions and 0 deletions
@@ -72,6 +72,31 @@ RifReaderOpmCommon::~RifReaderOpmCommon()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderOpmCommon::GridDimensions RifReaderOpmCommon::readGridDimensions( const QString& gridFileName )
{
GridDimensions result;
try
{
Opm::EclIO::EGrid opmGrid( gridFileName.toStdString() );
const auto& dims = opmGrid.dimension();
result.i = dims[0];
result.j = dims[1];
result.k = dims[2];
result.activeCellCount = opmGrid.activeCells();
}
catch ( std::exception& e )
{
RiaLogging::debug( QString( "Failed to read grid dimensions from %1: %2" ).arg( gridFileName ).arg( e.what() ) );
}
return result;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -53,6 +53,14 @@ class ProgressInfo;
class RifReaderOpmCommon : public RifReaderInterface
{
public:
struct GridDimensions
{
size_t i = 0;
size_t j = 0;
size_t k = 0;
size_t activeCellCount = 0;
};
RifReaderOpmCommon();
~RifReaderOpmCommon() override;
@@ -64,6 +72,8 @@ public:
std::vector<QDateTime> timeStepsOnFile( QString gridFileName );
std::set<RiaDefines::PhaseType> availablePhases() const override;
static GridDimensions readGridDimensions( const QString& gridFileName );
protected:
virtual bool importGrid( RigMainGrid* mainGrid, RigEclipseCaseData* caseData );