ResInsight/ApplicationLibCode/FileInterface/RifReaderOpmCommon.h
jonjenssen 0572069511
Support for loading only active cell geometry (#11624)
* Only load active cells for main grid, skip LGRs for now
* Handle wells with inactive cells
* Validate mapaxes transform before using it.
* Add log message
* Additional guarding when trying to find the geometrical location of a simulation cell
* Add extra safeguarding for init/restart file access in opm common. Only support unified restart files.
2024-08-28 18:22:57 +02:00

124 lines
4.2 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RifReaderInterface.h"
#include <memory>
#include <string>
#include <vector>
namespace Opm::EclIO
{
class EInit;
class ERst;
class EGrid;
} // namespace Opm::EclIO
class RigMainGrid;
class RigActiveCellGrid;
class RigGridBase;
class RigEclipseCaseData;
class RigEclipseTimeStepInfo;
namespace caf
{
class ProgressInfo;
}
//==================================================================================================
//
//
//==================================================================================================
class RifReaderOpmCommon : public RifReaderInterface
{
public:
RifReaderOpmCommon();
~RifReaderOpmCommon() override;
bool open( const QString& fileName, RigEclipseCaseData* caseData ) override;
bool staticResult( const QString& result, RiaDefines::PorosityModelType matrixOrFracture, std::vector<double>* values ) override;
bool dynamicResult( const QString& result, RiaDefines::PorosityModelType matrixOrFracture, size_t stepIndex, std::vector<double>* values ) override;
std::vector<QDateTime> timeStepsOnFile( QString gridFileName );
protected:
virtual bool importGrid( RigMainGrid* mainGrid, RigEclipseCaseData* caseData );
void transferActiveCells( Opm::EclIO::EGrid& opmGrid,
size_t cellStartIndex,
RigEclipseCaseData* eclipseCaseData,
size_t matrixActiveStartIndex,
size_t fractureActiveStartIndex );
void transferStaticNNCData( Opm::EclIO::EGrid& opmMainGrid, std::vector<Opm::EclIO::EGrid>& lgrGrids, RigMainGrid* mainGrid );
bool verifyActiveCellInfo( int activeSizeMat, int activeSizeFrac );
void updateActiveCellInfo( RigEclipseCaseData* eclipseCaseData,
Opm::EclIO::EGrid& opmGrid,
std::vector<Opm::EclIO::EGrid>& lgrGrids,
RigMainGrid* mainGrid );
private:
void buildMetaData( RigEclipseCaseData* caseData, caf::ProgressInfo& progress );
std::vector<RigEclipseTimeStepInfo> createFilteredTimeStepInfos();
std::vector<std::vector<int>> readActiveCellInfoFromPorv( RigEclipseCaseData* eclipseCaseData, bool isDualPorosity );
void transferGeometry( Opm::EclIO::EGrid& opmMainGrid,
Opm::EclIO::EGrid& opmGrid,
RigMainGrid* riMainGrid,
RigGridBase* riGrid,
RigEclipseCaseData* caseData );
void transferDynamicNNCData( RigMainGrid* mainGrid );
void locateInitAndRestartFiles( QString gridFileName );
void setupInitAndRestartAccess();
struct TimeDataFile
{
int sequenceNumber;
int year;
int month;
int day;
double simulationTimeFromStart;
};
std::vector<TimeDataFile> readTimeSteps();
protected:
enum class ActiveType
{
ACTIVE_MATRIX_VALUE = 1,
ACTIVE_FRACTURE_VALUE = 2
};
std::string m_gridFileName;
int m_gridUnit;
std::vector<std::string> m_gridNames;
RigEclipseCaseData* m_eclipseCaseData;
private:
std::string m_initFileName;
std::string m_restartFileName;
std::unique_ptr<Opm::EclIO::ERst> m_restartFile;
std::unique_ptr<Opm::EclIO::EInit> m_initFile;
};