Added reading of fracture model active index

Lots of renaming
p4#: 20302
This commit is contained in:
Magne Sjaastad
2013-01-30 14:13:50 +01:00
parent 4275e67a82
commit ce95f13c10
32 changed files with 343 additions and 255 deletions

View File

@@ -40,8 +40,8 @@ RigCell::RigCell() :
m_hostGrid(NULL),
m_isInvalid(false),
m_isWellCell(false),
m_globalMatrixActiveIndex(cvf::UNDEFINED_SIZE_T),
m_globalFractureActiveIndex(cvf::UNDEFINED_SIZE_T),
m_activeIndexInMatrixModel(cvf::UNDEFINED_SIZE_T),
m_activeIndexInFractureModel(cvf::UNDEFINED_SIZE_T),
m_cellIndex(cvf::UNDEFINED_SIZE_T)
{
memcpy(m_cornerIndices.m_array, undefinedCornersArray, 8*sizeof(size_t));

View File

@@ -34,16 +34,16 @@ public:
RigCell();
~RigCell(); // Not virtual, to save space. Do not inherit from this class
caf::SizeTArray8& cornerIndices() { return m_cornerIndices;}
const caf::SizeTArray8& cornerIndices() const { return m_cornerIndices;}
caf::SizeTArray8& cornerIndices() { return m_cornerIndices;}
const caf::SizeTArray8& cornerIndices() const { return m_cornerIndices;}
bool matrixActive() const { return m_globalMatrixActiveIndex != cvf::UNDEFINED_SIZE_T; }
size_t globalMatrixActiveIndex() const { return m_globalMatrixActiveIndex; }
void setGlobalMatrixActiveIndex(size_t val) { m_globalMatrixActiveIndex = val; }
bool isActiveInMatrixModel() const { return m_activeIndexInMatrixModel != cvf::UNDEFINED_SIZE_T; }
size_t activeIndexInMatrixModel() const { return m_activeIndexInMatrixModel; }
void setActiveIndexInMatrixModel(size_t val) { m_activeIndexInMatrixModel = val; }
bool fractureActive() const { return m_globalFractureActiveIndex != cvf::UNDEFINED_SIZE_T; }
size_t globalFractureActiveIndex() const { return m_globalFractureActiveIndex; }
void setGlobalFractureActiveIndex(size_t val) { m_globalFractureActiveIndex = val; }
bool isActiveInFractureModel() const { return m_activeIndexInFractureModel != cvf::UNDEFINED_SIZE_T; }
size_t activeIndexInFractureModel() const { return m_activeIndexInFractureModel; }
void setActiveIndexInFractureModel(size_t val) { m_activeIndexInFractureModel = val; }
bool isInvalid() const { return m_isInvalid; }
void setInvalid( bool val ) { m_isInvalid = val; }
@@ -87,8 +87,8 @@ private:
size_t m_parentCellIndex; ///< Grid cell index of the cell in the parent grid containing this cell
size_t m_mainGridCellIndex;
size_t m_globalMatrixActiveIndex; ///< This cell's running index of all the active calls in the reservoir. Used for result mapping
size_t m_globalFractureActiveIndex; ///< This cell's running index of all the active calls in the reservoir. Used for result mapping
size_t m_activeIndexInMatrixModel; ///< This cell's running index of all the active calls (matrix) in the reservoir
size_t m_activeIndexInFractureModel; ///< This cell's running index of all the active calls (fracture) in the reservoir
size_t m_cellIndex; ///< This cells index in the grid it belongs to.
};

View File

@@ -29,8 +29,8 @@ RigGridBase::RigGridBase(RigMainGrid* mainGrid):
m_gridPointDimensions(0,0,0),
m_mainGrid(mainGrid),
m_indexToStartOfCells(0),
m_matrixActiveCellCount(cvf::UNDEFINED_SIZE_T),
m_fractureActiveCellCount(cvf::UNDEFINED_SIZE_T)
m_matrixModelActiveCellCount(cvf::UNDEFINED_SIZE_T),
m_fractureModelActiveCellCount(cvf::UNDEFINED_SIZE_T)
{
if (mainGrid == NULL)
{
@@ -257,7 +257,7 @@ double RigGridBase::cellScalar(size_t timeStepIndex, size_t scalarSetIndex, size
bool useGlobalActiveIndex = m_mainGrid->results()->isUsingGlobalActiveIndex(scalarSetIndex);
if (useGlobalActiveIndex)
{
resultValueIndex = cell(cellIndex).globalMatrixActiveIndex();
resultValueIndex = cell(cellIndex).activeIndexInMatrixModel();
if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL;
}
@@ -359,7 +359,7 @@ bool RigGridBase::isCellActive(size_t i, size_t j, size_t k) const
{
size_t idx = cellIndexFromIJK(i, j, k);
const RigCell& c = cell(idx);
if (!c.matrixActive() || c.isInvalid())
if (!c.isActiveInMatrixModel() || c.isInvalid())
{
return false;
}
@@ -529,52 +529,52 @@ double RigGridBase::characteristicCellSize()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigGridBase::activeMatrixCellCount()
size_t RigGridBase::matrixModelActiveCellCount()
{
if (m_matrixActiveCellCount == cvf::UNDEFINED_SIZE_T)
if (m_matrixModelActiveCellCount == cvf::UNDEFINED_SIZE_T)
{
computeMatrixAndFractureActiveCellCount();
computeMatrixAndFractureModelActiveCellCount();
}
CVF_ASSERT(m_matrixActiveCellCount != cvf::UNDEFINED_SIZE_T);
CVF_ASSERT(m_matrixModelActiveCellCount != cvf::UNDEFINED_SIZE_T);
return m_matrixActiveCellCount;
return m_matrixModelActiveCellCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigGridBase::activeFractureCellCount()
size_t RigGridBase::fractureModelActiveCellCount()
{
if (m_fractureActiveCellCount == cvf::UNDEFINED_SIZE_T)
if (m_fractureModelActiveCellCount == cvf::UNDEFINED_SIZE_T)
{
computeMatrixAndFractureActiveCellCount();
computeMatrixAndFractureModelActiveCellCount();
}
CVF_ASSERT(m_fractureActiveCellCount != cvf::UNDEFINED_SIZE_T);
CVF_ASSERT(m_fractureModelActiveCellCount != cvf::UNDEFINED_SIZE_T);
return m_fractureActiveCellCount;
return m_fractureModelActiveCellCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGridBase::computeMatrixAndFractureActiveCellCount()
void RigGridBase::computeMatrixAndFractureModelActiveCellCount()
{
m_matrixActiveCellCount = 0;
m_fractureActiveCellCount = 0;
m_matrixModelActiveCellCount = 0;
m_fractureModelActiveCellCount = 0;
for (size_t i = 0; i < cellCount(); i++)
{
const RigCell& c = cell(i);
if (c.matrixActive())
if (c.isActiveInMatrixModel())
{
m_matrixActiveCellCount++;
m_matrixModelActiveCellCount++;
}
if (c.fractureActive())
if (c.isActiveInFractureModel())
{
m_fractureActiveCellCount++;
m_fractureModelActiveCellCount++;
}
}
}

View File

@@ -58,9 +58,9 @@ public:
bool isMainGrid() const;
RigMainGrid* mainGrid() const { return m_mainGrid; }
size_t activeMatrixCellCount();
size_t activeFractureCellCount();
void computeMatrixAndFractureActiveCellCount();
size_t matrixModelActiveCellCount();
size_t fractureModelActiveCellCount();
void computeMatrixAndFractureModelActiveCellCount();
protected:
friend class RigMainGrid;//::initAllSubGridsParentGridPointer();
@@ -109,8 +109,8 @@ private:
size_t m_gridIndex; ///< The LGR index of this grid. Starts with 1. Main grid has index 0.
RigMainGrid* m_mainGrid;
size_t m_matrixActiveCellCount;
size_t m_fractureActiveCellCount;
size_t m_matrixModelActiveCellCount;
size_t m_fractureModelActiveCellCount;
};

View File

@@ -29,7 +29,8 @@ RigMainGrid::RigMainGrid(void)
m_activeCellPositionMax(cvf::Vec3st::UNDEFINED),
m_validCellPositionMin(cvf::Vec3st::UNDEFINED),
m_validCellPositionMax(cvf::Vec3st::UNDEFINED),
m_globalMatrixActiveCellCount(cvf::UNDEFINED_SIZE_T)
m_globalMatrixModelActiveCellCount(cvf::UNDEFINED_SIZE_T),
m_globalFractureModelActiveCellCount(cvf::UNDEFINED_SIZE_T)
{
m_results = new RigReservoirCellResults(this);
@@ -79,35 +80,33 @@ void RigMainGrid::initAllSubCellsMainGridCellIndex()
}
//--------------------------------------------------------------------------------------------------
/// Calculates the number of active cells in the complete reservoir.
/// Caches the result, so subsequent calls are fast
///
//--------------------------------------------------------------------------------------------------
size_t RigMainGrid::globalMatrixActiveCellCount()
size_t RigMainGrid::globalMatrixModelActiveCellCount()
{
if (m_globalMatrixActiveCellCount != cvf::UNDEFINED_SIZE_T) return m_globalMatrixActiveCellCount;
if (m_globalMatrixModelActiveCellCount != cvf::UNDEFINED_SIZE_T) return m_globalMatrixModelActiveCellCount;
if (m_cells.size() == 0) return 0;
computeGlobalActiveCellCount();
size_t numActiveCells = 0;
size_t i;
for (i = 0; i < m_cells.size(); i++)
{
if (m_cells[i].matrixActive()) numActiveCells++;
}
m_globalMatrixActiveCellCount = numActiveCells;
return m_globalMatrixActiveCellCount;
return m_globalMatrixModelActiveCellCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigMainGrid::activeCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const
size_t RigMainGrid::globalFractureModelActiveCellCount()
{
if (m_globalFractureModelActiveCellCount != cvf::UNDEFINED_SIZE_T) return m_globalFractureModelActiveCellCount;
computeGlobalActiveCellCount();
return m_globalFractureModelActiveCellCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigMainGrid::matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const
{
min = m_activeCellPositionMin;
max = m_activeCellPositionMax;
@@ -116,7 +115,7 @@ void RigMainGrid::activeCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) con
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RigMainGrid::activeCellsBoundingBox() const
cvf::BoundingBox RigMainGrid::matrixModelActiveCellsBoundingBox() const
{
return m_activeCellsBoundingBox;
}
@@ -183,7 +182,7 @@ void RigMainGrid::computeActiveAndValidCellRanges()
validBB.add(i, j, k);
}
if (c.matrixActive())
if (c.isActiveInMatrixModel())
{
activeBB.add(i, j, k);
}
@@ -222,7 +221,7 @@ void RigMainGrid::computeBoundingBox()
for (i = 0; i < cellCount(); i++)
{
const RigCell& c = cell(i);
if (c.matrixActive())
if (c.isActiveInMatrixModel())
{
const caf::SizeTArray8& indices = c.cornerIndices();
@@ -256,7 +255,7 @@ void RigMainGrid::computeCachedData()
///
///
//--------------------------------------------------------------------------------------------------
void RigMainGrid::calculateActiveCellInfo(std::vector<qint32> &gridNumber,
void RigMainGrid::calculateMatrixModelActiveCellInfo(std::vector<qint32> &gridNumber,
std::vector<qint32> &cellI,
std::vector<qint32> &cellJ,
std::vector<qint32> &cellK,
@@ -265,7 +264,7 @@ void RigMainGrid::calculateActiveCellInfo(std::vector<qint32> &gridNumber,
std::vector<qint32> &hostCellJ,
std::vector<qint32> &hostCellK)
{
size_t numActiveCells = this->globalMatrixActiveCellCount();
size_t numMatrixModelActiveCells = this->globalMatrixModelActiveCellCount();
gridNumber.clear();
cellI.clear();
@@ -276,18 +275,18 @@ void RigMainGrid::calculateActiveCellInfo(std::vector<qint32> &gridNumber,
hostCellJ.clear();
hostCellK.clear();
gridNumber.reserve(numActiveCells);
cellI.reserve(numActiveCells);
cellJ.reserve(numActiveCells);
cellK.reserve(numActiveCells);
parentGridNumber.reserve(numActiveCells);
hostCellI.reserve(numActiveCells);
hostCellJ.reserve(numActiveCells);
hostCellK.reserve(numActiveCells);
gridNumber.reserve(numMatrixModelActiveCells);
cellI.reserve(numMatrixModelActiveCells);
cellJ.reserve(numMatrixModelActiveCells);
cellK.reserve(numMatrixModelActiveCells);
parentGridNumber.reserve(numMatrixModelActiveCells);
hostCellI.reserve(numMatrixModelActiveCells);
hostCellJ.reserve(numMatrixModelActiveCells);
hostCellK.reserve(numMatrixModelActiveCells);
for (size_t cIdx = 0; cIdx < m_cells.size(); ++cIdx)
{
if (m_cells[cIdx].matrixActive())
if (m_cells[cIdx].isActiveInMatrixModel())
{
RigGridBase* grid = m_cells[cIdx].hostGrid();
CVF_ASSERT(grid != NULL);
@@ -351,11 +350,27 @@ const RigGridBase* RigMainGrid::gridByIndex(size_t localGridIndex) const
//--------------------------------------------------------------------------------------------------
void RigMainGrid::computeActiveCellCountForAllGrids()
{
computeMatrixAndFractureActiveCellCount();
computeMatrixAndFractureModelActiveCellCount();
size_t i;
for (i = 0; i < m_localGrids.size(); ++i)
{
m_localGrids[i]->computeMatrixAndFractureActiveCellCount();
m_localGrids[i]->computeMatrixAndFractureModelActiveCellCount();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigMainGrid::computeGlobalActiveCellCount()
{
m_globalMatrixModelActiveCellCount = 0;
m_globalFractureModelActiveCellCount = 0;
size_t i;
for (i = 0; i < m_cells.size(); i++)
{
if (m_cells[i].isActiveInMatrixModel()) m_globalMatrixModelActiveCellCount++;
if (m_cells[i].isActiveInFractureModel()) m_globalFractureModelActiveCellCount++;
}
}

View File

@@ -43,8 +43,10 @@ public:
RigReservoirCellResults* results() {return m_results.p();}
const RigReservoirCellResults* results() const {return m_results.p();}
size_t globalMatrixActiveCellCount();
void activeCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const;
size_t globalMatrixModelActiveCellCount();
size_t globalFractureModelActiveCellCount();
void matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const;
void validCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const;
void addLocalGrid(RigLocalGrid* localGrid);
@@ -52,7 +54,7 @@ public:
RigGridBase* gridByIndex(size_t localGridIndex);
const RigGridBase* gridByIndex(size_t localGridIndex) const;
void calculateActiveCellInfo(std::vector<qint32>& gridNumber,
void calculateMatrixModelActiveCellInfo(std::vector<qint32>& gridNumber,
std::vector<qint32>& i,
std::vector<qint32>& j,
std::vector<qint32>& k,
@@ -62,7 +64,7 @@ public:
std::vector<qint32>& hostCellK);
void computeCachedData();
cvf::BoundingBox activeCellsBoundingBox() const;
cvf::BoundingBox matrixModelActiveCellsBoundingBox() const;
// Overrides
virtual cvf::Vec3d displayModelOffset() const;
@@ -72,6 +74,7 @@ private:
void initAllSubCellsMainGridCellIndex();
void computeActiveAndValidCellRanges();
void computeBoundingBox();
void computeGlobalActiveCellCount();
void computeActiveCellCountForAllGrids();
private:
@@ -79,7 +82,8 @@ private:
std::vector<RigCell> m_cells; ///< Global array of all cells in the reservoir (including the ones in LGR's)
cvf::Collection<RigLocalGrid> m_localGrids; ///< List of all the LGR's in this reservoir
cvf::ref<RigReservoirCellResults> m_results;
size_t m_globalMatrixActiveCellCount;
size_t m_globalMatrixModelActiveCellCount;
size_t m_globalFractureModelActiveCellCount;
cvf::Vec3st m_activeCellPositionMin;
cvf::Vec3st m_activeCellPositionMax;

View File

@@ -156,11 +156,11 @@ void RigReservoirBuilderMock::appendCells(size_t nodeStartIndex, size_t cellCoun
if (!(i % 5))
{
riCell.setGlobalMatrixActiveIndex(cvf::UNDEFINED_SIZE_T);
riCell.setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
}
else
{
riCell.setGlobalMatrixActiveIndex(activeCellIndex++);
riCell.setActiveIndexInMatrixModel(activeCellIndex++);
}
cells.push_back(riCell);
@@ -296,7 +296,7 @@ bool RigReservoirBuilderMock::staticResult(RigReservoir* reservoir, const QStrin
for (k = 0; k < reservoir->mainGrid()->cells().size(); k++)
{
RigCell& cell = reservoir->mainGrid()->cells()[k];
if (cell.matrixActive())
if (cell.isActiveInMatrixModel())
{
if (cell.hostGrid() == reservoir->mainGrid())
{
@@ -333,7 +333,7 @@ bool RigReservoirBuilderMock::dynamicResult(RigReservoir* reservoir, const QStri
for (k = 0; k < reservoir->mainGrid()->cells().size(); k++)
{
RigCell& cell = reservoir->mainGrid()->cells()[k];
if (cell.matrixActive())
if (cell.isActiveInMatrixModel())
{
if (cell.hostGrid() == reservoir->mainGrid())
{

View File

@@ -292,7 +292,7 @@ size_t RigReservoirCellResults::findOrLoadScalarResult(RimDefines::ResultCatType
for (i = 0; i < timeStepCount; i++)
{
std::vector<double>& values = m_cellScalarResults[resultGridIndex][i];
if (!m_readerInterface->dynamicResult(resultName, i, &values))
if (!m_readerInterface->dynamicResult(resultName, RifReaderInterface::MATRIX_RESULTS, i, &values))
{
resultLoadingSucess = false;
}
@@ -303,7 +303,7 @@ size_t RigReservoirCellResults::findOrLoadScalarResult(RimDefines::ResultCatType
m_cellScalarResults[resultGridIndex].resize(1);
std::vector<double>& values = m_cellScalarResults[resultGridIndex][0];
if (!m_readerInterface->staticResult(resultName, &values))
if (!m_readerInterface->staticResult(resultName, RifReaderInterface::MATRIX_RESULTS, &values))
{
resultLoadingSucess = false;
}
@@ -512,14 +512,14 @@ void RigReservoirCellResults::computeDepthRelatedResults()
std::vector< std::vector<double> >& tops = cellScalarResults(topsResultGridIndex);
std::vector< std::vector<double> >& bottom = cellScalarResults(bottomResultGridIndex);
bool computeValuesForActiveCellsOnly = m_ownerMainGrid->globalMatrixActiveCellCount() > 0;
bool computeValuesForActiveCellsOnly = m_ownerMainGrid->globalMatrixModelActiveCellCount() > 0;
size_t cellIdx = 0;
for (cellIdx = 0; cellIdx < m_ownerMainGrid->cells().size(); cellIdx++)
{
const RigCell& cell = m_ownerMainGrid->cells()[cellIdx];
if (computeValuesForActiveCellsOnly && !cell.matrixActive())
if (computeValuesForActiveCellsOnly && !cell.isActiveInMatrixModel())
{
continue;
}
@@ -651,7 +651,7 @@ bool RigReservoirCellResults::isUsingGlobalActiveIndex(size_t scalarResultIndex)
CVF_TIGHT_ASSERT(scalarResultIndex < m_cellScalarResults.size());
if (!m_cellScalarResults[scalarResultIndex].size()) return true;
if (m_cellScalarResults[scalarResultIndex][0].size() == m_ownerMainGrid->globalMatrixActiveCellCount()) return true;
if (m_cellScalarResults[scalarResultIndex][0].size() == m_ownerMainGrid->globalMatrixModelActiveCellCount()) return true;
if (m_cellScalarResults[scalarResultIndex][0].size() == m_ownerMainGrid->cellCount()) return false;
CVF_TIGHT_ASSERT(false); // Wrong number of results