mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-14 17:32:13 -05:00
Add support for grid import using opm-common
Add support for import of geometry and results for main grid. Currently no support for LGR. Add selection in Preferences to either use libecl or opm-common for grid import. If RESINSIGHT_DEVEL flag is set, display reader in an Eclipse case to make it possible to compare Eclipse and opm-common in same project. Add more includes to custom-opm-common to be able to support this functionality. opm-common is unchanged.
This commit is contained in:
1 parent
559f02c13a
commit
81809efee9
25 files changed
+1114
-120
No files matched your search
@@ -23,6 +23,8 @@
|
||||
|
||||
#include "RifReaderEclipseOutput.h"
|
||||
|
||||
#include "RigActiveCellInfo.h"
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigMainGrid.h"
|
||||
|
||||
#include "cvfGeometryTools.h"
|
||||
@@ -98,6 +100,61 @@ void RifOpmGridTools::importCoordinatesForRadialGrid( const std::string& gridFil
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RifOpmGridTools::cellCount( const std::string& gridFilePath )
|
||||
{
|
||||
Opm::EclIO::EGrid opmGrid( gridFilePath );
|
||||
|
||||
return opmGrid.totalNumberOfCells();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifOpmGridTools::importGrid( const std::string& gridFilePath, RigMainGrid* mainGrid, RigEclipseCaseData* caseData )
|
||||
{
|
||||
Opm::EclIO::EGrid opmGrid( gridFilePath );
|
||||
|
||||
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 );
|
||||
|
||||
transferCoordinatesCartesian( opmGrid, opmGrid, mainGrid, mainGrid, caseData );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::vector<int>> RifOpmGridTools::activeCellsFromActnumKeyword( Opm::EclIO::EGrid& grid )
|
||||
{
|
||||
auto arrayNames = grid.arrayNames();
|
||||
int actnumArrayIndex = -1;
|
||||
|
||||
for ( size_t i = 0; i < arrayNames.size(); i++ )
|
||||
{
|
||||
if ( arrayNames[i] == "ACTNUM" )
|
||||
{
|
||||
actnumArrayIndex = static_cast<int>( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( actnumArrayIndex < 0 ) return {};
|
||||
|
||||
auto actnumMainGrid = grid.get<int>( actnumArrayIndex );
|
||||
|
||||
return { actnumMainGrid };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// A radial grid is defined by a center point and a set of cylindrical coordinates. The coordinates at the
|
||||
@@ -251,6 +308,79 @@ void RifOpmGridTools::transferCoordinates( Opm::EclIO::EGrid& opmMainGrid, Opm::
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifOpmGridTools::transferCoordinatesCartesian( Opm::EclIO::EGrid& opmMainGrid,
|
||||
Opm::EclIO::EGrid& opmGrid,
|
||||
RigMainGrid* riMainGrid,
|
||||
RigGridBase* riGrid,
|
||||
RigEclipseCaseData* caseData )
|
||||
{
|
||||
// Prefix OPM structures with _opm_and ResInsight structures with _ri_
|
||||
|
||||
auto& riNodes = riMainGrid->nodes();
|
||||
|
||||
opmGrid.loadData();
|
||||
opmGrid.load_grid_data();
|
||||
|
||||
auto riActiveCells = caseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
||||
auto riActiveCellsFrac = caseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL );
|
||||
riActiveCellsFrac->setGridCount( 1 );
|
||||
riActiveCellsFrac->setGridActiveCellCounts( 0, 0 );
|
||||
|
||||
riActiveCells->setReservoirCellCount( riMainGrid->cellCount() );
|
||||
|
||||
// same mapping as libecl
|
||||
const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 };
|
||||
|
||||
#pragma omp parallel for
|
||||
for ( int opmCellIndex = 0; opmCellIndex < static_cast<int>( riMainGrid->cellCount() ); opmCellIndex++ )
|
||||
{
|
||||
auto opmIJK = opmGrid.ijk_from_global_index( opmCellIndex );
|
||||
|
||||
auto riReservoirIndex = riGrid->cellIndexFromIJK( opmIJK[0], opmIJK[1], opmIJK[2] );
|
||||
RigCell& cell = riMainGrid->globalCellArray()[riReservoirIndex];
|
||||
cell.setGridLocalCellIndex( riReservoirIndex );
|
||||
|
||||
std::array<double, 8> opmX{};
|
||||
std::array<double, 8> opmY{};
|
||||
std::array<double, 8> opmZ{};
|
||||
opmGrid.getCellCorners( opmCellIndex, opmX, opmY, opmZ );
|
||||
|
||||
// Each cell has 8 nodes, use reservoir cell index and multiply to find first node index for cell
|
||||
auto riNodeStartIndex = riReservoirIndex * 8;
|
||||
|
||||
for ( size_t opmNodeIndex = 0; opmNodeIndex < 8; opmNodeIndex++ )
|
||||
{
|
||||
auto riCornerIndex = cellMappingECLRi[opmNodeIndex];
|
||||
size_t riNodeIndex = riNodeStartIndex + riCornerIndex;
|
||||
|
||||
auto& riNode = riNodes[riNodeIndex];
|
||||
riNode.x() = opmX[opmNodeIndex];
|
||||
riNode.y() = opmY[opmNodeIndex];
|
||||
riNode.z() = -opmZ[opmNodeIndex];
|
||||
|
||||
cell.cornerIndices()[riCornerIndex] = riNodeIndex;
|
||||
}
|
||||
|
||||
if ( riActiveCells )
|
||||
{
|
||||
auto activeIndex = opmGrid.active_index( opmIJK[0], opmIJK[1], opmIJK[2] );
|
||||
if ( activeIndex > -1 )
|
||||
{
|
||||
riActiveCells->setCellResultIndex( riReservoirIndex, activeIndex );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
riActiveCells->setGridCount( 1 );
|
||||
riActiveCells->setGridActiveCellCounts( 0, opmGrid.activeCells() );
|
||||
riActiveCells->computeDerivedData();
|
||||
|
||||
riMainGrid->initAllSubGridsParentGridPointer();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user