mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
207 lines
8.8 KiB
C++
207 lines
8.8 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2024- 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.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RigActiveCellGrid.h"
|
|
|
|
#include "RigActiveCellInfo.h"
|
|
#include "RigEclipseCaseData.h"
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RigActiveCellGrid::RigActiveCellGrid()
|
|
{
|
|
m_invalidCell.setInvalid( true );
|
|
for ( size_t i = 0; i < 8; i++ )
|
|
m_invalidCell.cornerIndices()[i] = 0;
|
|
m_invalidCell.setHostGrid( this );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RigActiveCellGrid::~RigActiveCellGrid()
|
|
{
|
|
}
|
|
|
|
////--------------------------------------------------------------------------------------------------
|
|
/////
|
|
////--------------------------------------------------------------------------------------------------
|
|
// size_t RigActiveCellGrid::transferActiveInformation( int gridIndex,
|
|
// RigEclipseCaseData* eclipseCaseData,
|
|
// size_t totalActiveCells,
|
|
// size_t matrixActiveCells,
|
|
// size_t fractureActiveCells,
|
|
// const std::vector<int>& activeMatrixIndexes,
|
|
// const std::vector<int>& activeFracIndexes,
|
|
// size_t inactiveCellIndex )
|
|
//{
|
|
// if ( gridIndex == 0 )
|
|
// {
|
|
// m_globalToNativeMap.clear();
|
|
// inactiveCellIndex = 0;
|
|
// }
|
|
//
|
|
// const auto totalCells = activeMatrixIndexes.size();
|
|
//
|
|
// const auto cellStartIndex = m_globalToNativeMap.size();
|
|
//
|
|
// m_globalToNativeMap.resize( cellStartIndex + totalCells );
|
|
// size_t activeCells = cellStartIndex;
|
|
// size_t anInactiveCellIdx = inactiveCellIndex;
|
|
//
|
|
// for ( size_t i = 0; i < totalCells; i++ )
|
|
// {
|
|
// const auto globalCellIndex = cellStartIndex + i;
|
|
// if ( ( activeMatrixIndexes[i] < 0 ) && ( activeFracIndexes[i] < 0 ) )
|
|
// {
|
|
// m_globalToNativeMap[globalCellIndex] = totalActiveCells;
|
|
// anInactiveCellIdx = globalCellIndex;
|
|
// continue;
|
|
// }
|
|
// m_nativeToGlobalMap.push_back( globalCellIndex );
|
|
// m_globalToNativeMap[i] = activeCells++;
|
|
// }
|
|
// m_nativeToGlobalMap.push_back( anInactiveCellIdx );
|
|
//
|
|
// RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
|
// RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL );
|
|
//
|
|
// activeCellInfo->setReservoirCellCount( activeCellInfo->reservoirCellCount() + totalActiveCells + 1 );
|
|
// fractureActiveCellInfo->setReservoirCellCount( fractureActiveCellInfo->reservoirCellCount() + totalActiveCells + 1 );
|
|
//
|
|
// activeCellInfo->setGridCount( gridIndex + 1 );
|
|
// fractureActiveCellInfo->setGridCount( gridIndex + 1 );
|
|
//
|
|
// activeCellInfo->setGridActiveCellCounts( gridIndex, matrixActiveCells );
|
|
// fractureActiveCellInfo->setGridActiveCellCounts( gridIndex, fractureActiveCells );
|
|
//
|
|
// // TODO - update indexes here
|
|
//
|
|
// #pragma omp parallel for
|
|
// for ( int opmCellIndex = 0; opmCellIndex < (int)totalCells; opmCellIndex++ )
|
|
// {
|
|
// auto activeCellIndex = m_globalToNativeMap[cellStartIndex + opmCellIndex];
|
|
//
|
|
// // active cell index
|
|
// int matrixActiveIndex = activeMatrixIndexes[opmCellIndex];
|
|
// if ( matrixActiveIndex != -1 )
|
|
// {
|
|
// activeCellInfo->setCellResultIndex( activeCellIndex, matrixActiveIndex );
|
|
// }
|
|
//
|
|
// int fractureActiveIndex = activeFracIndexes[opmCellIndex];
|
|
// if ( fractureActiveIndex != -1 )
|
|
// {
|
|
// fractureActiveCellInfo->setCellResultIndex( activeCellIndex, fractureActiveIndex );
|
|
// }
|
|
// }
|
|
//
|
|
// return anInactiveCellIdx;
|
|
// }
|
|
|
|
////--------------------------------------------------------------------------------------------------
|
|
/////
|
|
////--------------------------------------------------------------------------------------------------
|
|
// size_t RigActiveCellGrid::cellIndexFromIJK( size_t i, size_t j, size_t k ) const
|
|
//{
|
|
// auto index = RigGridBase::cellIndexFromIJK( i, j, k );
|
|
// return m_globalToActiveMap[index];
|
|
// }
|
|
//
|
|
////--------------------------------------------------------------------------------------------------
|
|
/////
|
|
////--------------------------------------------------------------------------------------------------
|
|
// size_t RigActiveCellGrid::cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const
|
|
//{
|
|
// auto index = RigGridBase::cellIndexFromIJKUnguarded( i, j, k );
|
|
// return m_globalToActiveMap[index];
|
|
// }
|
|
//
|
|
////--------------------------------------------------------------------------------------------------
|
|
/////
|
|
////--------------------------------------------------------------------------------------------------
|
|
// bool RigActiveCellGrid::ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const
|
|
//{
|
|
// if ( cellIndex >= m_activeToGlobalMap.size() )
|
|
// {
|
|
// return false;
|
|
// }
|
|
// auto index = m_activeToGlobalMap[cellIndex];
|
|
// return RigGridBase::ijkFromCellIndex( index, i, j, k );
|
|
// }
|
|
//
|
|
////--------------------------------------------------------------------------------------------------
|
|
/////
|
|
////--------------------------------------------------------------------------------------------------
|
|
// void RigActiveCellGrid::ijkFromCellIndexUnguarded( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const
|
|
//{
|
|
// auto index = m_activeToGlobalMap[cellIndex];
|
|
// RigGridBase::ijkFromCellIndexUnguarded( index, i, j, k );
|
|
// }
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RigCell& RigActiveCellGrid::cell( size_t gridLocalCellIndex )
|
|
{
|
|
if ( m_nativeCells.contains( gridLocalCellIndex ) ) return m_nativeCells[gridLocalCellIndex];
|
|
return m_invalidCell;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
const RigCell& RigActiveCellGrid::cell( size_t gridLocalCellIndex ) const
|
|
{
|
|
if ( m_nativeCells.contains( gridLocalCellIndex ) ) return m_nativeCells.at( gridLocalCellIndex );
|
|
return m_invalidCell;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::map<size_t, RigCell>& RigActiveCellGrid::nativeCells()
|
|
{
|
|
return m_nativeCells;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
const std::map<size_t, RigCell>& RigActiveCellGrid::nativeCells() const
|
|
{
|
|
return m_nativeCells;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
size_t RigActiveCellGrid::totalCellCount() const
|
|
{
|
|
return m_totalCellCount;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RigActiveCellGrid::setTotalCellCount( size_t totalCellCount )
|
|
{
|
|
m_totalCellCount = totalCellCount;
|
|
}
|