mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1758 Refactor IJKCellIndex
This commit is contained in:
@@ -18,6 +18,10 @@
|
||||
|
||||
#include "RigCompletionData.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigMainGrid.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
@@ -79,7 +83,7 @@ RigCompletionData RigCompletionData::combine(const std::vector<RigCompletionData
|
||||
{
|
||||
if (it->completionType() != result.completionType())
|
||||
{
|
||||
RiaLogging::error(QString("Cannot combine completions of different types in same cell [%1, %2, %3]").arg(result.m_cellIndex.i).arg(result.m_cellIndex.j).arg(result.m_cellIndex.k));
|
||||
RiaLogging::error(QString("Cannot combine completions of different types in same cell [%1, %2, %3]").arg(result.m_cellIndex.localCellIndexI()).arg(result.m_cellIndex.localCellIndexJ()).arg(result.m_cellIndex.localCellIndexK()));
|
||||
continue;
|
||||
}
|
||||
if (onlyOneIsDefaulted(result.m_transmissibility, it->m_transmissibility))
|
||||
@@ -390,3 +394,76 @@ void RigCompletionData::copy(RigCompletionData& target, const RigCompletionData&
|
||||
target.m_wpimult = from.m_wpimult;
|
||||
target.m_completionType = from.m_completionType;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
IJKCellIndex::IJKCellIndex(size_t globalCellIndex, const RimEclipseCase* eclipseCase) : m_globalCellIndex(globalCellIndex)
|
||||
{
|
||||
if (eclipseCase && eclipseCase->eclipseCaseData() && eclipseCase->eclipseCaseData()->mainGrid())
|
||||
{
|
||||
const RigMainGrid* mainGrid = eclipseCase->eclipseCaseData()->mainGrid();
|
||||
const RigCell& cell = mainGrid->globalCellArray()[globalCellIndex];
|
||||
RigGridBase* grid = cell.hostGrid();
|
||||
if (grid)
|
||||
{
|
||||
size_t gridLocalCellIndex = cell.gridLocalCellIndex();
|
||||
|
||||
size_t i = 0;
|
||||
size_t j = 0;
|
||||
size_t k = 0;
|
||||
grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k);
|
||||
|
||||
m_localCellIndexI = i;
|
||||
m_localCellIndexJ = j;
|
||||
m_localCellIndexK = k;
|
||||
|
||||
if (grid != mainGrid)
|
||||
{
|
||||
m_lgrName = QString::fromStdString(grid->gridName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t IJKCellIndex::globalCellIndex() const
|
||||
{
|
||||
return m_globalCellIndex;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t IJKCellIndex::localCellIndexI() const
|
||||
{
|
||||
return m_localCellIndexI;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t IJKCellIndex::localCellIndexJ() const
|
||||
{
|
||||
return m_localCellIndexJ;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t IJKCellIndex::localCellIndexK() const
|
||||
{
|
||||
return m_localCellIndexK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString IJKCellIndex::oneBasedLocalCellIndexString() const
|
||||
{
|
||||
QString text = QString("[%1, %2, %3]").arg(m_localCellIndexI + 1).arg(m_localCellIndexJ + 1).arg(m_localCellIndexK + 1);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimEclipseCase;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
@@ -47,30 +49,44 @@ enum CellDirection {
|
||||
class IJKCellIndex {
|
||||
public:
|
||||
IJKCellIndex() {};
|
||||
IJKCellIndex(size_t i, size_t j, size_t k) : i(i), j(j), k(k) {};
|
||||
|
||||
IJKCellIndex(size_t globalCellIndex, const RimEclipseCase* eclipseCase);
|
||||
|
||||
IJKCellIndex(const IJKCellIndex& other)
|
||||
{
|
||||
i = other.i;
|
||||
j = other.j;
|
||||
k = other.k;
|
||||
m_localCellIndexI = other.m_localCellIndexI;
|
||||
m_localCellIndexJ = other.m_localCellIndexJ;
|
||||
m_localCellIndexK = other.m_localCellIndexK;
|
||||
}
|
||||
|
||||
bool operator==(const IJKCellIndex& other) const
|
||||
{
|
||||
return i == other.i && j == other.j && k == other.k;
|
||||
return m_localCellIndexI == other.m_localCellIndexI && m_localCellIndexJ == other.m_localCellIndexJ && m_localCellIndexK == other.m_localCellIndexK;
|
||||
}
|
||||
|
||||
bool operator<(const IJKCellIndex& other) const
|
||||
{
|
||||
if (i != other.i) return i < other.i;
|
||||
if (j != other.j) return j < other.j;
|
||||
if (k != other.k) return k < other.k;
|
||||
if (m_localCellIndexI != other.m_localCellIndexI) return m_localCellIndexI < other.m_localCellIndexI;
|
||||
if (m_localCellIndexJ != other.m_localCellIndexJ) return m_localCellIndexJ < other.m_localCellIndexJ;
|
||||
if (m_localCellIndexK != other.m_localCellIndexK) return m_localCellIndexK < other.m_localCellIndexK;
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t i;
|
||||
size_t j;
|
||||
size_t k;
|
||||
size_t globalCellIndex() const;
|
||||
|
||||
size_t localCellIndexI() const;
|
||||
size_t localCellIndexJ() const;
|
||||
size_t localCellIndexK() const;
|
||||
|
||||
QString oneBasedLocalCellIndexString() const;
|
||||
|
||||
private:
|
||||
size_t m_globalCellIndex;
|
||||
QString m_lgrName;
|
||||
|
||||
size_t m_localCellIndexI;
|
||||
size_t m_localCellIndexJ;
|
||||
size_t m_localCellIndexK;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
Reference in New Issue
Block a user