2013-02-11 08:12:53 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2014-09-23 08:04:57 -05:00
|
|
|
// Copyright (C) 2011- Statoil ASA
|
|
|
|
// Copyright (C) 2013- Ceetron Solutions AS
|
|
|
|
// Copyright (C) 2011-2012 Ceetron AS
|
2018-10-19 03:40:54 -05:00
|
|
|
//
|
2013-02-11 08:12:53 -06: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.
|
2018-10-19 03:40:54 -05:00
|
|
|
//
|
2013-02-11 08:12:53 -06: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.
|
2018-10-19 03:40:54 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2013-02-11 08:12:53 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RigActiveCellInfo.h"
|
|
|
|
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RigActiveCellInfo::RigActiveCellInfo()
|
2018-10-19 03:40:54 -05:00
|
|
|
: m_reservoirActiveCellCount(0)
|
|
|
|
, m_reservoirCellResultCount(0)
|
|
|
|
, m_activeCellPositionMin(cvf::Vec3d::ZERO)
|
|
|
|
, m_activeCellPositionMax(cvf::Vec3d::ZERO)
|
2013-02-12 00:11:32 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2014-08-08 03:45:52 -05:00
|
|
|
void RigActiveCellInfo::setReservoirCellCount(size_t reservoirCellCount)
|
2013-02-12 00:11:32 -06:00
|
|
|
{
|
2014-08-08 03:45:52 -05:00
|
|
|
m_cellIndexToResultIndex.resize(reservoirCellCount, cvf::UNDEFINED_SIZE_T);
|
2013-02-12 00:11:32 -06:00
|
|
|
}
|
|
|
|
|
2013-05-21 07:35:47 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2014-08-08 03:27:29 -05:00
|
|
|
size_t RigActiveCellInfo::reservoirCellCount() const
|
2013-05-21 07:35:47 -05:00
|
|
|
{
|
2013-05-21 13:43:03 -05:00
|
|
|
return m_cellIndexToResultIndex.size();
|
2013-05-21 07:35:47 -05:00
|
|
|
}
|
|
|
|
|
2013-05-26 04:59:59 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2014-08-08 03:27:29 -05:00
|
|
|
size_t RigActiveCellInfo::reservoirCellResultCount() const
|
2013-05-26 04:59:59 -05:00
|
|
|
{
|
2014-08-08 03:45:52 -05:00
|
|
|
return m_reservoirCellResultCount;
|
2013-05-26 04:59:59 -05:00
|
|
|
}
|
|
|
|
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2014-08-08 03:02:26 -05:00
|
|
|
bool RigActiveCellInfo::isActive(size_t reservoirCellIndex) const
|
2013-02-12 00:11:32 -06:00
|
|
|
{
|
2013-03-22 03:32:42 -05:00
|
|
|
if (m_cellIndexToResultIndex.size() == 0)
|
2013-03-07 07:56:52 -06:00
|
|
|
{
|
2013-03-21 04:31:58 -05:00
|
|
|
return true;
|
2013-03-07 07:56:52 -06:00
|
|
|
}
|
|
|
|
|
2014-08-08 03:02:26 -05:00
|
|
|
CVF_TIGHT_ASSERT(reservoirCellIndex < m_cellIndexToResultIndex.size());
|
2013-02-12 00:11:32 -06:00
|
|
|
|
2014-08-08 03:02:26 -05:00
|
|
|
return m_cellIndexToResultIndex[reservoirCellIndex] != cvf::UNDEFINED_SIZE_T;
|
2013-02-12 00:11:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2014-08-08 03:02:26 -05:00
|
|
|
size_t RigActiveCellInfo::cellResultIndex(size_t reservoirCellIndex) const
|
2013-02-12 00:11:32 -06:00
|
|
|
{
|
2013-03-22 03:32:42 -05:00
|
|
|
if (m_cellIndexToResultIndex.size() == 0)
|
2013-03-07 07:56:52 -06:00
|
|
|
{
|
2014-08-08 03:02:26 -05:00
|
|
|
return reservoirCellIndex;
|
2013-03-07 07:56:52 -06:00
|
|
|
}
|
|
|
|
|
2014-08-08 03:02:26 -05:00
|
|
|
CVF_TIGHT_ASSERT(reservoirCellIndex < m_cellIndexToResultIndex.size());
|
2013-02-12 00:11:32 -06:00
|
|
|
|
2014-08-08 03:02:26 -05:00
|
|
|
return m_cellIndexToResultIndex[reservoirCellIndex];
|
2013-02-12 00:11:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2014-08-08 03:45:52 -05:00
|
|
|
void RigActiveCellInfo::setCellResultIndex(size_t reservoirCellIndex, size_t reservoirCellResultIndex)
|
2013-02-12 00:11:32 -06:00
|
|
|
{
|
2014-08-08 03:45:52 -05:00
|
|
|
CVF_TIGHT_ASSERT(reservoirCellResultIndex < m_cellIndexToResultIndex.size());
|
2013-05-26 04:59:59 -05:00
|
|
|
|
2014-08-08 03:45:52 -05:00
|
|
|
m_cellIndexToResultIndex[reservoirCellIndex] = reservoirCellResultIndex;
|
2013-02-12 00:11:32 -06:00
|
|
|
|
2014-08-08 03:45:52 -05:00
|
|
|
if (reservoirCellResultIndex >= m_reservoirCellResultCount)
|
2013-05-26 04:59:59 -05:00
|
|
|
{
|
2014-08-08 03:45:52 -05:00
|
|
|
m_reservoirCellResultCount = reservoirCellResultIndex + 1;
|
2013-05-26 04:59:59 -05:00
|
|
|
}
|
2013-02-12 00:11:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RigActiveCellInfo::setGridCount(size_t gridCount)
|
|
|
|
{
|
|
|
|
m_perGridActiveCellInfo.resize(gridCount);
|
|
|
|
}
|
2013-03-13 05:50:31 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-03-13 05:50:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 03:32:42 -05:00
|
|
|
void RigActiveCellInfo::setGridActiveCellCounts(size_t gridIndex, size_t activeCellCount)
|
2013-03-13 05:50:31 -05:00
|
|
|
{
|
|
|
|
CVF_ASSERT(gridIndex < m_perGridActiveCellInfo.size());
|
|
|
|
|
2013-03-22 03:32:42 -05:00
|
|
|
m_perGridActiveCellInfo[gridIndex].setActiveCellCount(activeCellCount);
|
2013-02-12 00:11:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RigActiveCellInfo::computeDerivedData()
|
|
|
|
{
|
2014-08-08 03:45:52 -05:00
|
|
|
m_reservoirActiveCellCount = 0;
|
2013-02-12 00:11:32 -06:00
|
|
|
|
2013-03-06 08:13:37 -06:00
|
|
|
for (size_t i = 0; i < m_perGridActiveCellInfo.size(); i++)
|
2013-02-12 00:11:32 -06:00
|
|
|
{
|
2014-08-08 03:45:52 -05:00
|
|
|
m_reservoirActiveCellCount += m_perGridActiveCellInfo[i].activeCellCount();
|
2013-02-12 00:11:32 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2014-08-08 03:27:29 -05:00
|
|
|
size_t RigActiveCellInfo::reservoirActiveCellCount() const
|
2013-02-12 00:11:32 -06:00
|
|
|
{
|
2014-08-08 03:45:52 -05:00
|
|
|
return m_reservoirActiveCellCount;
|
2013-02-12 00:11:32 -06:00
|
|
|
}
|
2013-03-13 07:42:27 -05:00
|
|
|
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 03:32:42 -05:00
|
|
|
void RigActiveCellInfo::setIJKBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max)
|
2013-02-12 00:11:32 -06:00
|
|
|
{
|
|
|
|
m_activeCellPositionMin = min;
|
|
|
|
m_activeCellPositionMax = max;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 03:32:42 -05:00
|
|
|
void RigActiveCellInfo::IJKBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const
|
2013-02-12 00:11:32 -06:00
|
|
|
{
|
|
|
|
min = m_activeCellPositionMin;
|
|
|
|
max = m_activeCellPositionMax;
|
|
|
|
}
|
2013-02-12 04:15:36 -06:00
|
|
|
|
2013-03-13 05:50:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-03-13 05:50:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-08-22 09:59:22 -05:00
|
|
|
void RigActiveCellInfo::gridActiveCellCounts(size_t gridIndex, size_t& activeCellCount) const
|
2013-03-13 05:50:31 -05:00
|
|
|
{
|
2013-03-22 03:32:42 -05:00
|
|
|
activeCellCount = m_perGridActiveCellInfo[gridIndex].activeCellCount();
|
2013-03-13 05:50:31 -05:00
|
|
|
}
|
2013-02-13 04:04:45 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-02-13 04:04:45 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 03:32:42 -05:00
|
|
|
cvf::BoundingBox RigActiveCellInfo::geometryBoundingBox() const
|
2013-02-13 04:04:45 -06:00
|
|
|
{
|
2013-03-22 03:32:42 -05:00
|
|
|
return m_activeCellsBoundingBox;
|
2013-02-13 04:04:45 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-02-13 04:04:45 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 03:32:42 -05:00
|
|
|
void RigActiveCellInfo::setGeometryBoundingBox(cvf::BoundingBox bb)
|
2013-02-13 04:04:45 -06:00
|
|
|
{
|
2013-03-22 03:32:42 -05:00
|
|
|
m_activeCellsBoundingBox = bb;
|
2013-02-13 04:04:45 -06:00
|
|
|
}
|
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-03-21 09:31:47 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RigActiveCellInfo::clear()
|
|
|
|
{
|
|
|
|
m_perGridActiveCellInfo.clear();
|
2013-03-22 03:32:42 -05:00
|
|
|
m_cellIndexToResultIndex.clear();
|
2014-08-08 03:45:52 -05:00
|
|
|
m_reservoirActiveCellCount = 0;
|
2018-10-19 03:40:54 -05:00
|
|
|
m_activeCellPositionMin = cvf::Vec3st(0, 0, 0);
|
|
|
|
m_activeCellPositionMax = cvf::Vec3st(0, 0, 0);
|
2013-03-22 03:32:42 -05:00
|
|
|
m_activeCellsBoundingBox.reset();
|
2013-03-21 09:31:47 -05:00
|
|
|
}
|
|
|
|
|
2014-04-03 03:58:29 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-24 05:07:36 -05:00
|
|
|
void RigActiveCellInfo::addLgr(size_t cellCount)
|
2018-10-19 03:40:54 -05:00
|
|
|
{
|
2018-10-24 05:07:36 -05:00
|
|
|
size_t currentGridCount = m_perGridActiveCellInfo.size();
|
|
|
|
size_t currentActiveCellCount = reservoirActiveCellCount();
|
|
|
|
size_t currentReservoirCellCount = reservoirCellCount();
|
2018-10-19 03:40:54 -05:00
|
|
|
|
2018-10-24 05:07:36 -05:00
|
|
|
setGridCount(currentGridCount + 1);
|
|
|
|
setGridActiveCellCounts(currentGridCount, cellCount);
|
|
|
|
setReservoirCellCount(currentReservoirCellCount + cellCount);
|
2018-10-19 03:40:54 -05:00
|
|
|
|
2018-10-24 05:07:36 -05:00
|
|
|
computeDerivedData();
|
|
|
|
|
|
|
|
for (size_t i = 0; i < cellCount; i++)
|
2018-10-19 03:40:54 -05:00
|
|
|
{
|
2018-10-24 05:07:36 -05:00
|
|
|
setCellResultIndex(currentReservoirCellCount + i, currentActiveCellCount + i);
|
2018-10-19 03:40:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
2014-04-03 03:58:29 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RigActiveCellInfo::isCoarseningActive() const
|
|
|
|
{
|
2014-08-08 03:45:52 -05:00
|
|
|
return m_reservoirCellResultCount != m_reservoirActiveCellCount;
|
2014-04-03 03:58:29 -05:00
|
|
|
}
|
|
|
|
|
2017-03-06 04:58:07 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2017-03-06 04:58:07 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RigActiveCellInfo::GridActiveCellCounts::GridActiveCellCounts()
|
2018-10-19 03:40:54 -05:00
|
|
|
: m_activeCellCount(0)
|
2017-03-06 04:58:07 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 03:32:42 -05:00
|
|
|
size_t RigActiveCellInfo::GridActiveCellCounts::activeCellCount() const
|
2013-02-12 00:11:32 -06:00
|
|
|
{
|
2013-03-22 03:32:42 -05:00
|
|
|
return m_activeCellCount;
|
2013-02-12 00:11:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-19 03:40:54 -05:00
|
|
|
///
|
2013-02-12 00:11:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 03:32:42 -05:00
|
|
|
void RigActiveCellInfo::GridActiveCellCounts::setActiveCellCount(size_t activeCellCount)
|
2013-02-12 00:11:32 -06:00
|
|
|
{
|
2013-03-22 03:32:42 -05:00
|
|
|
m_activeCellCount = activeCellCount;
|
2013-02-12 00:11:32 -06:00
|
|
|
}
|