mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 07:00:17 -05:00
Migrate all assert macros in ApplicationLibCode to CAF_ASSERT and remove every use of cvfAssert.h. CVF_ASSERT is replaced one to one. CVF_TIGHT_ASSERT is also replaced by CAF_ASSERT, which is semantically exact: CVF_ENABLE_TIGHT_ASSERTS is 1 only under _DEBUG, and that is what CAF_ASSERT now does. The two CVF_FAIL_MSG sites become CAF_ASSERT( false && "message" ), preserving the message with the idiom already used elsewhere in the code base. Counts before and after: CVF_ASSERT 1044 to 0, CVF_TIGHT_ASSERT 66 to 0, CVF_FAIL_MSG 2 to 0, cvfAssert.h references 154 to 0. Include handling: files that included cvfAssert.h directly now include cafAssert.h instead, includes left dead by the migration are removed, and files that were relying on cvfAssert.h transitively get an explicit cafAssert.h. Files that reach cafAssert.h through another caf header are left unchanged; a missing include here is a compile error, not a silently disabled assert. ResultStatisticsCache links only LibCore and therefore had no path to cafAssert.h. Add the cafPdmCore directory as a private include path rather than linking the library, since cafAssert.h is header only. Note that this stops these asserts from firing in Release and RelWithDebInfo, where CVF_ASSERT was previously active.
238 lines
9.4 KiB
C++
238 lines
9.4 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2011- Statoil ASA
|
|
// Copyright (C) 2013- Ceetron Solutions AS
|
|
// Copyright (C) 2011-2012 Ceetron AS
|
|
//
|
|
// 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 "RigActiveCellInfo.h"
|
|
|
|
#include "cafAssert.h"
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RigActiveCellInfo::RigActiveCellInfo()
|
|
: m_reservoirActiveCellCount( 0 )
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RigActiveCellInfo::setReservoirCellCount( size_t reservoirCellCount )
|
|
{
|
|
m_reservoirCellToActiveCell.resize( reservoirCellCount, ActiveCellIndex( cvf::UNDEFINED_SIZE_T ) );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
size_t RigActiveCellInfo::reservoirCellCount() const
|
|
{
|
|
return m_reservoirCellToActiveCell.size();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RigActiveCellInfo::isActive( ReservoirCellIndex reservoirCellIndex ) const
|
|
{
|
|
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() );
|
|
|
|
return m_reservoirCellToActiveCell[reservoirCellIndex.value()];
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RigActiveCellInfo::setCellResultIndex( ReservoirCellIndex reservoirCellIndex, ActiveCellIndex reservoirCellResultIndex )
|
|
{
|
|
CAF_ASSERT( reservoirCellResultIndex.value() < m_reservoirCellToActiveCell.size() );
|
|
|
|
m_reservoirCellToActiveCell[reservoirCellIndex.value()] = reservoirCellResultIndex;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<ReservoirCellIndex> RigActiveCellInfo::activeReservoirCellIndices() const
|
|
{
|
|
return m_activeReservoirCells;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RigActiveCellInfo::setGridCount( size_t gridCount )
|
|
{
|
|
m_perGridActiveCellInfo.resize( gridCount );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RigActiveCellInfo::setGridActiveCellCounts( size_t gridIndex, size_t activeCellCount )
|
|
{
|
|
CAF_ASSERT( gridIndex < m_perGridActiveCellInfo.size() );
|
|
|
|
m_perGridActiveCellInfo[gridIndex].setActiveCellCount( activeCellCount );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RigActiveCellInfo::computeDerivedData()
|
|
{
|
|
m_reservoirActiveCellCount = 0;
|
|
m_activeReservoirCells.clear(); // make idempotent: callers may recompute after the cell set changes
|
|
|
|
for ( size_t i = 0; i < m_perGridActiveCellInfo.size(); i++ )
|
|
{
|
|
m_reservoirActiveCellCount += m_perGridActiveCellInfo[i].activeCellCount();
|
|
}
|
|
|
|
for ( size_t i = 0; i < m_reservoirCellToActiveCell.size(); i++ )
|
|
{
|
|
if ( m_reservoirCellToActiveCell[i].value() != cvf::UNDEFINED_SIZE_T )
|
|
{
|
|
m_activeReservoirCells.push_back( ReservoirCellIndex( i ) );
|
|
}
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
size_t RigActiveCellInfo::reservoirActiveCellCount() const
|
|
{
|
|
return m_reservoirActiveCellCount;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RigActiveCellInfo::setIjkBoundingBox( const RigBoundingBoxIjk<caf::VecIjk0>& boundingBox )
|
|
{
|
|
m_ijkBoundingBox = boundingBox;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
const RigBoundingBoxIjk<caf::VecIjk0>& RigActiveCellInfo::ijkBoundingBox() const
|
|
{
|
|
return m_ijkBoundingBox;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
size_t RigActiveCellInfo::gridActiveCellCounts( size_t gridIndex ) const
|
|
{
|
|
if ( gridIndex >= m_perGridActiveCellInfo.size() ) return 0;
|
|
|
|
return m_perGridActiveCellInfo[gridIndex].activeCellCount();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
cvf::BoundingBox RigActiveCellInfo::geometryBoundingBox() const
|
|
{
|
|
return m_activeCellsBoundingBox;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RigActiveCellInfo::setGeometryBoundingBox( cvf::BoundingBox bb )
|
|
{
|
|
m_activeCellsBoundingBox = bb;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RigActiveCellInfo::clear()
|
|
{
|
|
m_perGridActiveCellInfo.clear();
|
|
m_reservoirCellToActiveCell.clear();
|
|
m_reservoirActiveCellCount = 0;
|
|
m_ijkBoundingBox = RigBoundingBoxIjk<caf::VecIjk0>();
|
|
m_activeCellsBoundingBox.reset();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
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 )
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
size_t RigActiveCellInfo::GridActiveCellCounts::activeCellCount() const
|
|
{
|
|
return m_activeCellCount;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RigActiveCellInfo::GridActiveCellCounts::setActiveCellCount( size_t activeCellCount )
|
|
{
|
|
m_activeCellCount = activeCellCount;
|
|
}
|