Use active cell info structure

p4#: 20455
This commit is contained in:
Magne Sjaastad 2013-02-12 11:15:36 +01:00
parent 0bc3d9f205
commit 2b4edf39d1
10 changed files with 190 additions and 52 deletions

View File

@ -84,8 +84,10 @@ static const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 };
// Static functions
//**************************************************************************************************
bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const ecl_grid_type* localEclGrid, size_t matrixActiveStartIndex, size_t fractureActiveStartIndex)
bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellInfo, RigGridBase* localGrid, const ecl_grid_type* localEclGrid, size_t matrixActiveStartIndex, size_t fractureActiveStartIndex)
{
CVF_ASSERT(activeCellInfo);
int cellCount = ecl_grid_get_global_size(localEclGrid);
size_t cellStartIndex = mainGrid->cells().size();
size_t nodeStartIndex = mainGrid->nodes().size();
@ -103,30 +105,32 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e
// Loop over cells and fill them with data
#pragma omp parallel for
for (int gIdx = 0; gIdx < cellCount; ++gIdx)
for (int localCellIdx = 0; localCellIdx < cellCount; ++localCellIdx)
{
RigCell& cell = mainGrid->cells()[cellStartIndex + gIdx];
RigCell& cell = mainGrid->cells()[cellStartIndex + localCellIdx];
bool invalid = ecl_grid_cell_invalid1(localEclGrid, gIdx);
bool invalid = ecl_grid_cell_invalid1(localEclGrid, localCellIdx);
cell.setInvalid(invalid);
cell.setCellIndex(gIdx);
cell.setCellIndex(localCellIdx);
// Active cell index
int matrixActiveIndex = ecl_grid_get_active_index1(localEclGrid, gIdx);
int matrixActiveIndex = ecl_grid_get_active_index1(localEclGrid, localCellIdx);
if (matrixActiveIndex != -1)
{
cell.setActiveIndexInMatrixModel(matrixActiveStartIndex + matrixActiveIndex);
activeCellInfo->setActiveIndexInMatrixModel(localCellIdx, matrixActiveStartIndex + matrixActiveIndex);
}
else
{
cell.setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
}
int fractureActiveIndex = ecl_grid_get_active_fracture_index1(localEclGrid, gIdx);
int fractureActiveIndex = ecl_grid_get_active_fracture_index1(localEclGrid, localCellIdx);
if (fractureActiveIndex != -1)
{
cell.setActiveIndexInFractureModel(fractureActiveStartIndex + fractureActiveIndex);
activeCellInfo->setActiveIndexInFractureModel(localCellIdx, fractureActiveStartIndex + fractureActiveIndex);
}
else
{
@ -135,7 +139,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e
// Parent cell index
int parentCellIndex = ecl_grid_get_parent_cell1(localEclGrid, gIdx);
int parentCellIndex = ecl_grid_get_parent_cell1(localEclGrid, localCellIdx);
if (parentCellIndex == -1)
{
cell.setParentCellIndex(cvf::UNDEFINED_SIZE_T);
@ -146,21 +150,21 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e
}
// Coarse cell info
ecl_coarse_cell_type * coarseCellData = ecl_grid_get_cell_coarse_group1( localEclGrid , gIdx);
ecl_coarse_cell_type * coarseCellData = ecl_grid_get_cell_coarse_group1( localEclGrid , localCellIdx);
cell.setInCoarseCell(coarseCellData != NULL);
// Corner coordinates
int cIdx;
for (cIdx = 0; cIdx < 8; ++cIdx)
{
double * point = mainGrid->nodes()[nodeStartIndex + gIdx * 8 + cellMappingECLRi[cIdx]].ptr();
ecl_grid_get_corner_xyz1(localEclGrid, gIdx, cIdx, &(point[0]), &(point[1]), &(point[2]));
double * point = mainGrid->nodes()[nodeStartIndex + localCellIdx * 8 + cellMappingECLRi[cIdx]].ptr();
ecl_grid_get_corner_xyz1(localEclGrid, localCellIdx, cIdx, &(point[0]), &(point[1]), &(point[2]));
point[2] = -point[2];
cell.cornerIndices()[cIdx] = nodeStartIndex + gIdx*8 + cIdx;
cell.cornerIndices()[cIdx] = nodeStartIndex + localCellIdx*8 + cIdx;
}
// Sub grid in cell
const ecl_grid_type* subGrid = ecl_grid_get_cell_lgr1(localEclGrid, gIdx);
const ecl_grid_type* subGrid = ecl_grid_get_cell_lgr1(localEclGrid, localCellIdx);
if (subGrid != NULL)
{
int subGridFileIndex = ecl_grid_get_grid_nr(subGrid);
@ -214,7 +218,7 @@ void RifReaderEclipseOutput::ground()
m_fileSet.clear();
m_timeSteps.clear();
m_mainGrid = NULL;
m_reservoir = NULL;
}
//--------------------------------------------------------------------------------------------------
@ -241,6 +245,9 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
return false;
}
RigActiveCellInfo* activeCellInfo = reservoir->activeCellInfo();
CVF_ASSERT(activeCellInfo);
RigMainGrid* mainGrid = reservoir->mainGrid();
{
cvf::Vec3st gridPointDim(0,0,0);
@ -275,6 +282,8 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
totalCellCount += ecl_grid_get_global_size(localEclGrid);
}
activeCellInfo->setGlobalCellCount(totalCellCount);
// Reserve room for the cells and nodes and fill them with data
@ -285,13 +294,16 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
progInfo.setProgressDescription("Main Grid");
progInfo.setNextProgressIncrement(3);
transferGridCellData(mainGrid, mainGrid, mainEclGrid, 0, 0);
transferGridCellData(mainGrid, activeCellInfo, mainGrid, mainEclGrid, 0, 0);
progInfo.setProgress(3);
size_t globalMatrixActiveSize = ecl_grid_get_nactive(mainEclGrid);
size_t globalFractureActiveSize = ecl_grid_get_nactive_fracture(mainEclGrid);
activeCellInfo->setGridCount(1 + numLGRs);
activeCellInfo->setGridActiveCellCounts(0, globalMatrixActiveSize, globalFractureActiveSize);
mainGrid->setMatrixModelActiveCellCount(globalMatrixActiveSize);
mainGrid->setFractureModelActiveCellCount(globalFractureActiveSize);
@ -302,23 +314,26 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
ecl_grid_type* localEclGrid = ecl_grid_iget_lgr(mainEclGrid, lgrIdx);
RigLocalGrid* localGrid = static_cast<RigLocalGrid*>(mainGrid->gridByIndex(lgrIdx+1));
transferGridCellData(mainGrid, localGrid, localEclGrid, globalMatrixActiveSize, globalFractureActiveSize);
transferGridCellData(mainGrid, activeCellInfo, localGrid, localEclGrid, globalMatrixActiveSize, globalFractureActiveSize);
int activeCellCount = ecl_grid_get_nactive(localEclGrid);
localGrid->setMatrixModelActiveCellCount(activeCellCount);
globalMatrixActiveSize += activeCellCount;
int matrixActiveCellCount = ecl_grid_get_nactive(localEclGrid);
localGrid->setMatrixModelActiveCellCount(matrixActiveCellCount);
globalMatrixActiveSize += matrixActiveCellCount;
activeCellCount = ecl_grid_get_nactive_fracture(localEclGrid);
localGrid->setFractureModelActiveCellCount(activeCellCount);
globalFractureActiveSize += activeCellCount;
int fractureActiveCellCount = ecl_grid_get_nactive_fracture(localEclGrid);
localGrid->setFractureModelActiveCellCount(fractureActiveCellCount);
globalFractureActiveSize += fractureActiveCellCount;
activeCellInfo->setGridActiveCellCounts(lgrIdx + 1, matrixActiveCellCount, fractureActiveCellCount);
progInfo.setProgress(3 + lgrIdx);
}
mainGrid->setGlobalMatrixModelActiveCellCount(globalMatrixActiveSize);
mainGrid->setGlobalFractureModelActiveCellCount(globalFractureActiveSize);
activeCellInfo->computeDerivedData();
return true;
}
@ -363,7 +378,7 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservo
progInfo.setProgressDescription("Reading Result index");
progInfo.setNextProgressIncrement(60);
m_mainGrid = reservoir->mainGrid();
m_reservoir = reservoir;
reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this);
reservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this);
@ -386,7 +401,7 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservo
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
{
CVF_ASSERT(reservoir);
CVF_ASSERT(m_reservoir.notNull());
CVF_ASSERT(m_fileSet.size() > 0);
caf::ProgressInfo progInfo(m_fileSet.size() + 3,"");
@ -402,8 +417,8 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
progInfo.incrementProgress();
RigReservoirCellResults* matrixModelResults = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS);
RigReservoirCellResults* fractureModelResults = reservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS);
RigReservoirCellResults* matrixModelResults = m_reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS);
RigReservoirCellResults* fractureModelResults = m_reservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS);
if (m_dynamicResultsAccess.notNull())
{
@ -415,7 +430,7 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
m_dynamicResultsAccess->resultNames(&resultNames, &resultNamesDataItemCounts);
{
QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::MATRIX_RESULTS, m_dynamicResultsAccess->timeStepCount());
QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_reservoir->activeCellInfo(), RifReaderInterface::MATRIX_RESULTS, m_dynamicResultsAccess->timeStepCount());
for (int i = 0; i < matrixResultNames.size(); ++i)
{
@ -425,7 +440,7 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
}
{
QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::FRACTURE_RESULTS, m_dynamicResultsAccess->timeStepCount());
QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_reservoir->activeCellInfo(), RifReaderInterface::FRACTURE_RESULTS, m_dynamicResultsAccess->timeStepCount());
for (int i = 0; i < fractureResultNames.size(); ++i)
{
@ -451,7 +466,7 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(ecl_file, &resultNames, &resultNamesDataItemCounts);
{
QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::MATRIX_RESULTS, 1);
QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_reservoir->activeCellInfo(), RifReaderInterface::MATRIX_RESULTS, 1);
QList<QDateTime> staticDate;
if (m_timeSteps.size() > 0)
@ -467,7 +482,7 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
}
{
QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::FRACTURE_RESULTS, 1);
QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_reservoir->activeCellInfo(), RifReaderInterface::FRACTURE_RESULTS, 1);
QList<QDateTime> staticDate;
if (m_timeSteps.size() > 0)
@ -559,7 +574,7 @@ bool RifReaderEclipseOutput::dynamicResult(const QString& result, PorosityModelR
CVF_ASSERT(m_dynamicResultsAccess.notNull());
std::vector<double> fileValues;
if (!m_dynamicResultsAccess->results(result, stepIndex, m_mainGrid->gridCount(), &fileValues))
if (!m_dynamicResultsAccess->results(result, stepIndex, m_reservoir->mainGrid()->gridCount(), &fileValues))
{
return false;
}
@ -752,8 +767,10 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringList& keywords, const std::vector<size_t>& keywordDataItemCounts, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const
QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringList& keywords, const std::vector<size_t>& keywordDataItemCounts, const RigActiveCellInfo* activeCellInfo, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const
{
CVF_ASSERT(activeCellInfo);
if (keywords.size() != keywordDataItemCounts.size())
{
return QStringList();
@ -761,7 +778,7 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL
if (matrixOrFracture == RifReaderInterface::FRACTURE_RESULTS)
{
if (m_mainGrid->globalFractureModelActiveCellCount() == 0)
if (activeCellInfo->globalFractureModelActiveCellCount() == 0)
{
return QStringList();
}
@ -774,11 +791,11 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL
QString keyword = keywords[i];
size_t keywordDataCount = keywordDataItemCounts[i];
size_t timeStepsMatrix = keywordDataItemCounts[i] / m_mainGrid->globalMatrixModelActiveCellCount();
size_t timeStepsMatrixRest = keywordDataItemCounts[i] % m_mainGrid->globalMatrixModelActiveCellCount();
size_t timeStepsMatrix = keywordDataItemCounts[i] / activeCellInfo->globalMatrixModelActiveCellCount();
size_t timeStepsMatrixRest = keywordDataItemCounts[i] % activeCellInfo->globalMatrixModelActiveCellCount();
size_t timeStepsMatrixAndFracture = keywordDataItemCounts[i] / (m_mainGrid->globalMatrixModelActiveCellCount() + m_mainGrid->globalFractureModelActiveCellCount());
size_t timeStepsMatrixAndFractureRest = keywordDataItemCounts[i] % (m_mainGrid->globalMatrixModelActiveCellCount() + m_mainGrid->globalFractureModelActiveCellCount());
size_t timeStepsMatrixAndFracture = keywordDataItemCounts[i] / (activeCellInfo->globalMatrixModelActiveCellCount() + activeCellInfo->globalFractureModelActiveCellCount());
size_t timeStepsMatrixAndFractureRest = keywordDataItemCounts[i] % (activeCellInfo->globalMatrixModelActiveCellCount() + activeCellInfo->globalFractureModelActiveCellCount());
if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS)
{
@ -807,9 +824,11 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector<double>* destinationResultValues, const std::vector<double>& sourceResultValues)
{
RigActiveCellInfo* actCellInfo = m_reservoir->activeCellInfo();
if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS)
{
if (m_mainGrid->globalFractureModelActiveCellCount() == 0)
if (actCellInfo->globalFractureModelActiveCellCount() == 0)
{
destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin(), sourceResultValues.end());
}
@ -818,10 +837,11 @@ void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityMod
size_t dataItemCount = 0;
size_t sourceStartPosition = 0;
for (size_t i = 0; i < m_mainGrid->gridCount(); i++)
for (size_t i = 0; i < m_reservoir->mainGrid()->gridCount(); i++)
{
size_t matrixActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount();
size_t fractureActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount();
size_t matrixActiveCellCount = 0;
size_t fractureActiveCellCount = 0;
actCellInfo->gridActiveCellCounts(i, matrixActiveCellCount, fractureActiveCellCount);
destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin() + sourceStartPosition, sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount);
@ -834,10 +854,11 @@ void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityMod
size_t dataItemCount = 0;
size_t sourceStartPosition = 0;
for (size_t i = 0; i < m_mainGrid->gridCount(); i++)
for (size_t i = 0; i < m_reservoir->mainGrid()->gridCount(); i++)
{
size_t matrixActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount();
size_t fractureActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount();
size_t matrixActiveCellCount = 0;
size_t fractureActiveCellCount = 0;
actCellInfo->gridActiveCellCounts(i, matrixActiveCellCount, fractureActiveCellCount);
destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount, sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount + fractureActiveCellCount);

View File

@ -26,6 +26,7 @@ class RifEclipseOutputFileTools;
class RifEclipseRestartDataAccess;
class RigGridBase;
class RigMainGrid;
class RigActiveCellInfo;
typedef struct ecl_grid_struct ecl_grid_type;
typedef struct ecl_file_struct ecl_file_type;
@ -60,13 +61,13 @@ private:
static RifEclipseRestartDataAccess* staticResultsAccess(const QStringList& fileSet);
static RifEclipseRestartDataAccess* dynamicResultsAccess(const QStringList& fileSet);
QStringList validKeywordsForPorosityModel(const QStringList& keywords, const std::vector<size_t>& keywordDataItemCounts, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const;
QStringList validKeywordsForPorosityModel(const QStringList& keywords, const std::vector<size_t>& keywordDataItemCounts, const RigActiveCellInfo* activeCellInfo, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const;
private:
QString m_fileName; // Name of file used to start accessing Eclipse output files
QStringList m_fileSet; // Set of files in filename's path with same base name as filename
cvf::cref<RigMainGrid> m_mainGrid;
cvf::ref<RigReservoir> m_reservoir;
QList<QDateTime> m_timeSteps;

View File

@ -114,7 +114,7 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames)
{
m_gridFileName = filenames[i];
m_rigReservoir->computeFaults();
m_rigReservoir->computeCachedData();
m_rigReservoir->mainGrid()->computeCachedData();
break;
@ -204,7 +204,7 @@ bool RimInputReservoir::openEclipseGridFile()
m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
m_rigReservoir->computeFaults();
m_rigReservoir->computeCachedData();
m_rigReservoir->mainGrid()->computeCachedData();
}

View File

@ -106,7 +106,7 @@ bool RimResultReservoir::openEclipseGridFile()
CVF_ASSERT(readerInterface.notNull());
progInfo.setProgressDescription("Computing Faults");
m_rigReservoir->computeFaults();
m_rigReservoir->computeCachedData();
progInfo.incrementProgress();
progInfo.setProgressDescription("Computing Cache");

View File

@ -37,6 +37,7 @@ RigActiveCellInfo::RigActiveCellInfo()
void RigActiveCellInfo::setGlobalCellCount(size_t globalCellCount)
{
m_activeInMatrixModel.resize(globalCellCount, cvf::UNDEFINED_SIZE_T);
m_activeInFractureModel.resize(globalCellCount, cvf::UNDEFINED_SIZE_T);
}
//--------------------------------------------------------------------------------------------------
@ -191,6 +192,15 @@ void RigActiveCellInfo::fractureModelActiveCellsBoundingBox(cvf::Vec3st& min, cv
max = m_fractureModelActiveCellPositionMax;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount, size_t& fractureActiveCellCount)
{
matrixActiveCellCount = m_perGridActiveCellInfo[gridIndex].matrixModelActiveCellCount();
fractureActiveCellCount = m_perGridActiveCellInfo[gridIndex].fractureModelActiveCellCount();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -45,6 +45,7 @@ public:
// From RigBase
void setGridCount(size_t gridCount);
void setGridActiveCellCounts(size_t gridIndex, size_t matrixActiveCellCount, size_t fractureActiveCellCount);
void gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount, size_t& fractureActiveCellCount);
void computeDerivedData();

View File

@ -499,6 +499,13 @@ void RigGridBase::setMatrixModelActiveCellCount(size_t activeMatrixModelCellCoun
m_matrixModelActiveCellCount = activeMatrixModelCellCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigGridBase::mainGridCellIndex(size_t localGridCellIndex) const
{
return m_indexToStartOfCells + localGridCellIndex;
}
//--------------------------------------------------------------------------------------------------
///

View File

@ -48,7 +48,9 @@ public:
RigCell& cell(size_t gridCellIndex);
const RigCell& cell(size_t gridCellIndex) const;
size_t mainGridCellIndex(size_t localGridCellIndex) const;
void setIndexToStartOfCells(size_t indexToStartOfCells) { m_indexToStartOfCells = indexToStartOfCells; }
void setGridIndex(size_t index) { m_gridIndex = index; }
size_t gridIndex() { return m_gridIndex; }

View File

@ -222,3 +222,91 @@ bool RigReservoir::findSharedSourceFace(cvf::StructGridInterface::FaceType& shar
return false;
}
//--------------------------------------------------------------------------------------------------
/// Helper class used to find min/max range for valid and active cells
//--------------------------------------------------------------------------------------------------
class CellRangeBB
{
public:
CellRangeBB()
: m_min(cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T),
m_max(cvf::Vec3st::ZERO)
{
}
void add(size_t i, size_t j, size_t k)
{
if (i < m_min.x()) m_min.x() = i;
if (j < m_min.y()) m_min.y() = j;
if (k < m_min.z()) m_min.z() = k;
if (i > m_max.x()) m_max.x() = i;
if (j > m_max.y()) m_max.y() = j;
if (k > m_max.z()) m_max.z() = k;
}
public:
cvf::Vec3st m_min;
cvf::Vec3st m_max;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoir::computeActiveCellData()
{
CellRangeBB matrixModelActiveBB;
CellRangeBB fractureModelActiveBB;
size_t idx;
for (idx = 0; idx < m_mainGrid->cellCount(); idx++)
{
const RigCell& c = m_mainGrid->cell(idx);
size_t i, j, k;
m_mainGrid->ijkFromCellIndex(idx, &i, &j, &k);
if (c.isActiveInMatrixModel())
{
matrixModelActiveBB.add(i, j, k);
}
if (c.isActiveInFractureModel())
{
fractureModelActiveBB.add(i, j, k);
}
}
m_activeCellInfo.setMatrixModelActiveCellsBoundingBox(matrixModelActiveBB.m_min, matrixModelActiveBB.m_max);
m_activeCellInfo.setFractureModelActiveCellsBoundingBox(fractureModelActiveBB.m_min, fractureModelActiveBB.m_max);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoir::computeCachedData()
{
computeFaults();
computeActiveCellData();
//TODO Set display model offset
/*
if (m_mainGrid.notNull())
{
m_mainGrid->setDisplayModelOffset(m_activeCellInfo.m_activeCellPositionMin);
}
*/
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigActiveCellInfo* RigReservoir::activeCellInfo()
{
return &m_activeCellInfo;
}

View File

@ -25,6 +25,7 @@
#include "cvfObject.h"
#include "RigMainGrid.h"
#include "RigWellResults.h"
#include "RigActiveCellInfo.h"
class RigReservoir: public cvf::Object
@ -40,17 +41,20 @@ public:
void allGrids(std::vector<const RigGridBase*>* grids) const;
const RigGridBase* grid(size_t index) const;
void computeCachedData();
void setWellResults(const cvf::Collection<RigWellResults>& data);
const cvf::Collection<RigWellResults>& wellResults() { return m_wellResults; }
cvf::UByteArray* wellCellsInGrid(size_t gridIndex);
void computeFaults();
RigCell& cellFromWellResultCell(const RigWellResultCell& wellResultCell);
bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const;
RigActiveCellInfo* activeCellInfo();
/*
// From RigMainGrid, can this function be moved to Octave socket server?
void calculateMatrixModelActiveCellInfo(std::vector<qint32>& gridNumber,
std::vector<qint32>& i,
@ -60,11 +64,15 @@ public:
std::vector<qint32>& hostCellI,
std::vector<qint32>& hostCellJ,
std::vector<qint32>& hostCellK);
*/
private:
void computeFaults();
void computeActiveCellData();
void computeWellCellsPrGrid();
private:
RigActiveCellInfo m_activeCellInfo;
cvf::ref<RigMainGrid> m_mainGrid;
cvf::Collection<RigWellResults> m_wellResults;