Skip to content

Commit

Permalink
Experiments in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Mar 19, 2024
1 parent 35493b5 commit 33d4d9d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 19 deletions.
10 changes: 0 additions & 10 deletions ApplicationLibCode/FileInterface/RifOpmGridTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,6 @@ void RifOpmGridTools::importCoordinatesForRadialGrid( const std::string& gridFil
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RifOpmGridTools::cellCount( const std::string& gridFilePath )
{
Opm::EclIO::EGrid opmGrid( gridFilePath );

return opmGrid.totalNumberOfCells();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions ApplicationLibCode/FileInterface/RifOpmGridTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ class RifOpmGridTools
// If the grid is radial, the coordinates are imported and adjusted to fit the host cells
static void importCoordinatesForRadialGrid( const std::string& gridFilePath, RigMainGrid* mainGrid );

static size_t cellCount( const std::string& gridFilePath );
static bool importGrid( const std::string& gridFilePath, RigMainGrid* mainGrid, RigEclipseCaseData* caseData );
static bool importGrid( const std::string& gridFilePath, RigMainGrid* mainGrid, RigEclipseCaseData* caseData );

static std::vector<std::vector<int>> activeCellsFromActnumKeyword( Opm::EclIO::EGrid& grid );

private:
static void transferCoordinates( Opm::EclIO::EGrid& opmMainGrid, Opm::EclIO::EGrid& opmGrid, RigMainGrid* riMainGrid, RigGridBase* riGrid );
static void transferCoordinatesCartesian( Opm::EclIO::EGrid& opmMainGrid,
Opm::EclIO::EGrid& opmGrid,
Expand Down
56 changes: 52 additions & 4 deletions ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "opm/input/eclipse/Parser/Parser.hpp"
#include "opm/input/eclipse/Schedule/Well/Connection.hpp"
#include "opm/input/eclipse/Schedule/Well/Well.hpp"
#include "opm/io/eclipse/EGrid.hpp"
#include "opm/io/eclipse/EInit.hpp"
#include "opm/io/eclipse/ERst.hpp"
#include "opm/io/eclipse/RestartFileView.hpp"
Expand Down Expand Up @@ -65,7 +66,7 @@ RifReaderOpmCommon::~RifReaderOpmCommon()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* eclipseCase )
bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* caseData )
{
caf::ProgressInfo progress( 100, "Reading Grid" );

Expand All @@ -76,7 +77,7 @@ bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* ecli
{
m_gridFileName = fileName.toStdString();

if ( !RifOpmGridTools::importGrid( m_gridFileName, eclipseCase->mainGrid(), eclipseCase ) )
if ( !RifOpmGridTools::importGrid( m_gridFileName, caseData->mainGrid(), caseData ) )
{
RiaLogging::error( "Failed to open grid file " + fileName );

Expand All @@ -92,14 +93,14 @@ bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* ecli

importFaults( fileSet, &faults );

RigMainGrid* mainGrid = eclipseCase->mainGrid();
RigMainGrid* mainGrid = caseData->mainGrid();
mainGrid->setFaults( faults );
}
}

{
auto task = progress.task( "Reading Results Meta data", 50 );
buildMetaData( eclipseCase );
buildMetaData( caseData );
}

return true;
Expand All @@ -113,6 +114,53 @@ bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* ecli
return true;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderOpmCommon::importGrid( RigMainGrid* mainGrid, RigEclipseCaseData* caseData )
{
Opm::EclIO::EGrid opmGrid( m_gridFileName );

const auto& dims = opmGrid.dimension();
mainGrid->setGridPointDimensions( cvf::Vec3st( dims[0] + 1, dims[1] + 1, dims[2] + 1 ) );

RigCell defaultCell;
defaultCell.setHostGrid( mainGrid );
auto cellCount = opmGrid.totalNumberOfCells();
mainGrid->globalCellArray().resize( cellCount, defaultCell );
mainGrid->nodes().resize( 8 * cellCount );

RifOpmGridTools::transferCoordinatesCartesian( opmGrid, opmGrid, mainGrid, mainGrid, caseData );

auto opmMapAxes = opmGrid.get_mapaxes();
if ( opmMapAxes.size() == 6 )
{
std::array<double, 6> mapAxes;
for ( size_t i = 0; i < opmMapAxes.size(); ++i )
{
mapAxes[i] = opmMapAxes[i];
}

// Set the map axes transformation matrix on the main grid
mainGrid->setMapAxes( mapAxes );
mainGrid->setUseMapAxes( true );

auto transform = mainGrid->mapAxisTransform();

// Invert the transformation matrix to convert from file coordinates to domain coordinates
transform.invert();

#pragma omp parallel for
for ( long i = 0; i < static_cast<long>( mainGrid->nodes().size() ); i++ )
{
auto& n = mainGrid->nodes()[i];
n.transformPoint( transform );
}
}

return true;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
7 changes: 5 additions & 2 deletions ApplicationLibCode/FileInterface/RifReaderOpmCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class EInit;
class ERst;
} // namespace Opm::EclIO

class RigMainGrid;

//==================================================================================================
//
//
Expand All @@ -38,13 +40,14 @@ class RifReaderOpmCommon : public RifReaderInterface
RifReaderOpmCommon();
~RifReaderOpmCommon() override;

bool open( const QString& fileName, RigEclipseCaseData* eclipseCase ) 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;

private:
void buildMetaData( RigEclipseCaseData* eclipseCase );
void buildMetaData( RigEclipseCaseData* caseData );
bool importGrid( RigMainGrid* mainGrid, RigEclipseCaseData* caseData );

struct TimeDataFile
{
Expand Down

0 comments on commit 33d4d9d

Please sign in to comment.