Files
ResInsight/ApplicationLibCode/ReservoirDataModel/RigActiveCellInfo.cpp
T

237 lines
9.4 KiB
C++
Raw Normal View History

2013-02-11 15:12:53 +01:00
/////////////////////////////////////////////////////////////////////////////////
//
2014-09-23 15:04:57 +02:00
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
2013-02-11 15:12:53 +01:00
// 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.
//
2013-02-11 15:12:53 +01:00
// 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>
2013-02-11 15:12:53 +01:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigActiveCellInfo.h"
#include "cafAssert.h"
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
///
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
RigActiveCellInfo::RigActiveCellInfo()
: m_reservoirActiveCellCount( 0 )
2013-02-12 07:11:32 +01:00
{
}
//--------------------------------------------------------------------------------------------------
///
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setReservoirCellCount( size_t reservoirCellCount )
2013-02-12 07:11:32 +01:00
{
m_reservoirCellToActiveCell.resize( reservoirCellCount, ActiveCellIndex( cvf::UNDEFINED_SIZE_T ) );
2013-02-12 07:11:32 +01:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2014-08-08 10:27:29 +02:00
size_t RigActiveCellInfo::reservoirCellCount() const
{
return m_reservoirCellToActiveCell.size();
}
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
///
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
bool RigActiveCellInfo::isActive( ReservoirCellIndex reservoirCellIndex ) const
2013-02-12 07:11:32 +01:00
{
if ( m_reservoirCellToActiveCell.empty() )
{
return true;
}
CAF_ASSERT( reservoirCellIndex.value() < m_reservoirCellToActiveCell.size() );
return m_reservoirCellToActiveCell[reservoirCellIndex.value()].value() != cvf::UNDEFINED_SIZE_T;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ActiveCellIndex RigActiveCellInfo::cellResultIndex( ReservoirCellIndex reservoirCellIndex ) const
{
CAF_ASSERT( reservoirCellIndex.value() < m_reservoirCellToActiveCell.size() );
2013-02-12 07:11:32 +01:00
return m_reservoirCellToActiveCell[reservoirCellIndex.value()];
2013-02-12 07:11:32 +01:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setCellResultIndex( ReservoirCellIndex reservoirCellIndex, ActiveCellIndex reservoirCellResultIndex )
{
CAF_ASSERT( reservoirCellResultIndex.value() < m_reservoirCellToActiveCell.size() );
m_reservoirCellToActiveCell[reservoirCellIndex.value()] = reservoirCellResultIndex;
2013-02-12 07:11:32 +01:00
}
2023-11-29 09:08:03 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<ReservoirCellIndex> RigActiveCellInfo::activeReservoirCellIndices() const
2023-11-29 09:08:03 +01:00
{
return m_activeReservoirCells;
2023-11-29 09:08:03 +01:00
}
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
///
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setGridCount( size_t gridCount )
2013-02-12 07:11:32 +01:00
{
m_perGridActiveCellInfo.resize( gridCount );
2013-02-12 07:11:32 +01:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setGridActiveCellCounts( size_t gridIndex, size_t activeCellCount )
{
CAF_ASSERT( gridIndex < m_perGridActiveCellInfo.size() );
m_perGridActiveCellInfo[gridIndex].setActiveCellCount( activeCellCount );
2013-02-12 07:11:32 +01:00
}
//--------------------------------------------------------------------------------------------------
///
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::computeDerivedData()
{
2014-08-08 10:45:52 +02:00
m_reservoirActiveCellCount = 0;
m_activeReservoirCells.clear(); // make idempotent: callers may recompute after the cell set changes
2013-02-12 07:11:32 +01:00
for ( size_t i = 0; i < m_perGridActiveCellInfo.size(); i++ )
2013-02-12 07:11:32 +01:00
{
2014-08-08 10:45:52 +02:00
m_reservoirActiveCellCount += m_perGridActiveCellInfo[i].activeCellCount();
2013-02-12 07:11:32 +01:00
}
2023-11-29 09:08:03 +01:00
for ( size_t i = 0; i < m_reservoirCellToActiveCell.size(); i++ )
2023-11-29 09:08:03 +01:00
{
if ( m_reservoirCellToActiveCell[i].value() != cvf::UNDEFINED_SIZE_T )
2023-11-29 09:08:03 +01:00
{
m_activeReservoirCells.push_back( ReservoirCellIndex( i ) );
2023-11-29 09:08:03 +01:00
}
}
2013-02-12 07:11:32 +01:00
}
//--------------------------------------------------------------------------------------------------
///
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
2014-08-08 10:27:29 +02:00
size_t RigActiveCellInfo::reservoirActiveCellCount() const
2013-02-12 07:11:32 +01:00
{
2014-08-08 10:45:52 +02:00
return m_reservoirActiveCellCount;
2013-02-12 07:11:32 +01:00
}
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
///
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setIjkBoundingBox( const RigBoundingBoxIjk<caf::VecIjk0>& boundingBox )
2013-02-12 07:11:32 +01:00
{
m_ijkBoundingBox = boundingBox;
2013-02-12 07:11:32 +01:00
}
//--------------------------------------------------------------------------------------------------
///
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
const RigBoundingBoxIjk<caf::VecIjk0>& RigActiveCellInfo::ijkBoundingBox() const
2013-02-12 07:11:32 +01:00
{
return m_ijkBoundingBox;
2013-02-12 07:11:32 +01:00
}
2013-02-12 11:15:36 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2022-11-24 10:44:03 +01:00
size_t RigActiveCellInfo::gridActiveCellCounts( size_t gridIndex ) const
{
if ( gridIndex >= m_perGridActiveCellInfo.size() ) return 0;
2022-11-24 10:44:03 +01:00
return m_perGridActiveCellInfo[gridIndex].activeCellCount();
}
2022-11-24 10:44:03 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2013-03-22 09:32:42 +01:00
cvf::BoundingBox RigActiveCellInfo::geometryBoundingBox() const
{
2013-03-22 09:32:42 +01:00
return m_activeCellsBoundingBox;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setGeometryBoundingBox( cvf::BoundingBox bb )
{
2013-03-22 09:32:42 +01:00
m_activeCellsBoundingBox = bb;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::clear()
{
m_perGridActiveCellInfo.clear();
m_reservoirCellToActiveCell.clear();
2014-08-08 10:45:52 +02:00
m_reservoirActiveCellCount = 0;
m_ijkBoundingBox = RigBoundingBoxIjk<caf::VecIjk0>();
2013-03-22 09:32:42 +01:00
m_activeCellsBoundingBox.reset();
}
2014-04-03 10:58:29 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::addLgr( size_t cellCount )
{
size_t currentGridCount = m_perGridActiveCellInfo.size();
size_t currentActiveCellCount = reservoirActiveCellCount();
size_t currentReservoirCellCount = reservoirCellCount();
setGridCount( currentGridCount + 1 );
setGridActiveCellCounts( currentGridCount, cellCount );
setReservoirCellCount( currentReservoirCellCount + cellCount );
computeDerivedData();
for ( size_t i = 0; i < cellCount; i++ )
{
setCellResultIndex( ReservoirCellIndex( currentReservoirCellCount + i ), ActiveCellIndex( currentActiveCellCount + i ) );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigActiveCellInfo::GridActiveCellCounts::GridActiveCellCounts()
: m_activeCellCount( 0 )
{
}
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
///
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
2013-03-22 09:32:42 +01:00
size_t RigActiveCellInfo::GridActiveCellCounts::activeCellCount() const
2013-02-12 07:11:32 +01:00
{
2013-03-22 09:32:42 +01:00
return m_activeCellCount;
2013-02-12 07:11:32 +01:00
}
//--------------------------------------------------------------------------------------------------
///
2013-02-12 07:11:32 +01:00
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::GridActiveCellCounts::setActiveCellCount( size_t activeCellCount )
2013-02-12 07:11:32 +01:00
{
2013-03-22 09:32:42 +01:00
m_activeCellCount = activeCellCount;
2013-02-12 07:11:32 +01:00
}