mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Restructured data access objects, added factory method
p4#: 20471
This commit is contained in:
parent
d45aded7f7
commit
1a17875dc1
@ -418,7 +418,8 @@ bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileNa
|
||||
return false;
|
||||
}
|
||||
|
||||
cvf::ref<RigGridScalarDataAccess> dataAccessObject = reservoir->mainGrid()->dataAccessObject(porosityModel, timeStep, resultIndex);
|
||||
RigActiveCellInfo* activeCellInfo = reservoir->activeCellInfo();
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = reservoir->mainGrid()->dataAccessObject(activeCellInfo, porosityModel, timeStep, resultIndex);
|
||||
if (dataAccessObject.isNull())
|
||||
{
|
||||
return false;
|
||||
|
@ -119,7 +119,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn
|
||||
if (matrixActiveIndex != -1)
|
||||
{
|
||||
cell.setActiveIndexInMatrixModel(matrixActiveStartIndex + matrixActiveIndex);
|
||||
activeCellInfo->setActiveIndexInMatrixModel(localCellIdx, matrixActiveStartIndex + matrixActiveIndex);
|
||||
activeCellInfo->setActiveIndexInMatrixModel(cellStartIndex + localCellIdx, matrixActiveStartIndex + matrixActiveIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -130,7 +130,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn
|
||||
if (fractureActiveIndex != -1)
|
||||
{
|
||||
cell.setActiveIndexInFractureModel(fractureActiveStartIndex + fractureActiveIndex);
|
||||
activeCellInfo->setActiveIndexInFractureModel(localCellIdx, fractureActiveStartIndex + fractureActiveIndex);
|
||||
activeCellInfo->setActiveIndexInFractureModel(cellStartIndex + localCellIdx, fractureActiveStartIndex + fractureActiveIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RigGridScalarDataAccess.h"
|
||||
#include "RigReservoirCellResults.h"
|
||||
#include "RigReservoir.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -221,7 +222,10 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
||||
if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0;
|
||||
|
||||
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
|
||||
cvf::ref<RigGridScalarDataAccess> dataAccessObject = m_grid->dataAccessObject(porosityModel, resTimeStepIdx, scalarSetIndex);
|
||||
|
||||
RigActiveCellInfo* activeCellInfo = cellResultSlot->reservoirView()->eclipseCase()->reservoirData()->activeCellInfo();
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = m_grid->dataAccessObject(activeCellInfo, porosityModel, resTimeStepIdx, scalarSetIndex);
|
||||
|
||||
if (dataAccessObject.isNull()) return;
|
||||
|
||||
// Outer surface
|
||||
|
@ -246,10 +246,13 @@ void RivReservoirViewPartMgr::createGeometry(ReservoirGeometryCacheType geometry
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, ReservoirGeometryCacheType geometryType, RigGridBase* grid, size_t gridIdx)
|
||||
{
|
||||
RigReservoir* reservoir = m_reservoirView->eclipseCase()->reservoirData();
|
||||
RigActiveCellInfo* activeCellInfo = reservoir->activeCellInfo();
|
||||
|
||||
switch (geometryType)
|
||||
{
|
||||
case ACTIVE:
|
||||
computeNativeVisibility(cellVisibility, grid, false, false, true, m_reservoirView->showMainGrid() );
|
||||
computeNativeVisibility(cellVisibility, grid, activeCellInfo, false, false, true, m_reservoirView->showMainGrid() );
|
||||
break;
|
||||
case ALL_WELL_CELLS:
|
||||
computeAllWellCellsVisibility(cellVisibility, grid);
|
||||
@ -287,7 +290,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility,
|
||||
}
|
||||
break;
|
||||
case INACTIVE:
|
||||
computeNativeVisibility(cellVisibility, grid, m_reservoirView->showInvalidCells(), true, false, m_reservoirView->showMainGrid());
|
||||
computeNativeVisibility(cellVisibility, grid, activeCellInfo, m_reservoirView->showInvalidCells(), true, false, m_reservoirView->showMainGrid());
|
||||
break;
|
||||
case RANGE_FILTERED:
|
||||
{
|
||||
@ -460,7 +463,7 @@ void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameInd
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Evaluate visibility based on cell state
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid,
|
||||
void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid, const RigActiveCellInfo* activeCellInfo,
|
||||
bool invalidCellsIsVisible,
|
||||
bool inactiveCellsIsVisible,
|
||||
bool activeCellsIsVisible,
|
||||
@ -468,16 +471,18 @@ void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisib
|
||||
{
|
||||
CVF_ASSERT(cellVisibility != NULL);
|
||||
CVF_ASSERT(grid != NULL);
|
||||
CVF_ASSERT(activeCellInfo != NULL);
|
||||
cellVisibility->resize(grid->cellCount());
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int cellIndex = 0; cellIndex < static_cast<int>(grid->cellCount()); cellIndex++)
|
||||
{
|
||||
const RigCell& cell = grid->cell(cellIndex);
|
||||
size_t globalCellIndex = cell.mainGridCellIndex();
|
||||
|
||||
if ( !invalidCellsIsVisible && cell.isInvalid()
|
||||
|| !inactiveCellsIsVisible && !cell.isActiveInMatrixModel()
|
||||
|| !activeCellsIsVisible && cell.isActiveInMatrixModel()
|
||||
|| !inactiveCellsIsVisible && !activeCellInfo->isActiveInMatrixModel(globalCellIndex)
|
||||
|| !activeCellsIsVisible && activeCellInfo->isActiveInMatrixModel(globalCellIndex)
|
||||
|| mainGridIsVisible && (cell.subGrid() != NULL)
|
||||
|| cell.isWellCell()
|
||||
)
|
||||
@ -600,7 +605,9 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis
|
||||
const RimCellFilter::FilterModeType filterType = (*pfIt)->filterMode();
|
||||
|
||||
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel((*pfIt)->resultDefinition()->porosityModel());
|
||||
cvf::ref<RigGridScalarDataAccess> dataAccessObject = grid->dataAccessObject(porosityModel, timeStepIndex, scalarResultIndex);
|
||||
RigActiveCellInfo* activeCellInfo = propFilterColl->reservoirView()->eclipseCase()->reservoirData()->activeCellInfo();
|
||||
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = grid->dataAccessObject(activeCellInfo, porosityModel, timeStepIndex, scalarResultIndex);
|
||||
CVF_ASSERT(dataAccessObject.notNull());
|
||||
|
||||
#pragma omp parallel for schedule(dynamic)
|
||||
|
@ -28,6 +28,7 @@ class RimReservoirView;
|
||||
class RigGridBase;
|
||||
class RimCellRangeFilterCollection;
|
||||
class RimCellPropertyFilterCollection;
|
||||
class RigActiveCellInfo;
|
||||
|
||||
class RivReservoirViewPartMgr: public cvf::Object
|
||||
{
|
||||
@ -77,7 +78,7 @@ private:
|
||||
void clearGeometryCache(ReservoirGeometryCacheType geomType);
|
||||
|
||||
|
||||
static void computeNativeVisibility (cvf::UByteArray* cellVisibility, const RigGridBase* grid, bool invalidCellsIsVisible, bool inactiveCellsIsVisible, bool activeCellsIsVisible, bool mainGridIsVisible);
|
||||
static void computeNativeVisibility (cvf::UByteArray* cellVisibility, const RigGridBase* grid, const RigActiveCellInfo* activeCellInfo, bool invalidCellsIsVisible, bool inactiveCellsIsVisible, bool activeCellsIsVisible, bool mainGridIsVisible);
|
||||
static void computeRangeVisibility (cvf::UByteArray* cellVisibility, const RigGridBase* grid, const cvf::UByteArray* nativeVisibility, const RimCellRangeFilterCollection* rangeFilterColl);
|
||||
static void computePropertyVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid, size_t timeStepIndex, const cvf::UByteArray* rangeFilterVisibility, RimCellPropertyFilterCollection* propFilterColl);
|
||||
static void computeAllWellCellsVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid );
|
||||
|
@ -870,10 +870,12 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex,
|
||||
{
|
||||
const RigReservoir* reservoir = m_reservoir->reservoirData();
|
||||
const RigGridBase* grid = reservoir->grid(gridIndex);
|
||||
const RigActiveCellInfo* activeCellInfo = reservoir->activeCellInfo();
|
||||
|
||||
if (this->cellResult()->hasResult())
|
||||
{
|
||||
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel());
|
||||
cvf::ref<RigGridScalarDataAccess> dataAccessObject = grid->dataAccessObject(porosityModel, m_currentTimeStep, this->cellResult()->gridScalarIndex());
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = grid->dataAccessObject(activeCellInfo, porosityModel, m_currentTimeStep, this->cellResult()->gridScalarIndex());
|
||||
if (dataAccessObject.notNull())
|
||||
{
|
||||
double scalarValue = dataAccessObject->cellScalar(cellIndex);
|
||||
@ -894,7 +896,7 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex,
|
||||
|
||||
// Cell edge results are static, results are loaded for first time step only
|
||||
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel());
|
||||
cvf::ref<RigGridScalarDataAccess> dataAccessObject = grid->dataAccessObject(porosityModel, 0, resultIndices[idx]);
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = grid->dataAccessObject(activeCellInfo, porosityModel, 0, resultIndices[idx]);
|
||||
if (dataAccessObject.notNull())
|
||||
{
|
||||
double scalarValue = dataAccessObject->cellScalar(cellIndex);
|
||||
|
@ -471,12 +471,12 @@ size_t RigGridBase::fractureModelActiveCellCount() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RigGridScalarDataAccess> RigGridBase::dataAccessObject(RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> RigGridBase::dataAccessObject(const RigActiveCellInfo* activeCellInfo, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const
|
||||
{
|
||||
if (timeStepIndex != cvf::UNDEFINED_SIZE_T &&
|
||||
scalarSetIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
cvf::ref<RigGridScalarDataAccess> dataAccess = RigGridScalarDataAccess::createDataAccessObject(this, porosityModel, timeStepIndex, scalarSetIndex);
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccess = RigGridScalarDataAccessFactory::createDataAccessObject(this, activeCellInfo, porosityModel, timeStepIndex, scalarSetIndex);
|
||||
return dataAccess;
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
class RigMainGrid;
|
||||
class RigCell;
|
||||
class RigGridScalarDataAccess;
|
||||
class RigActiveCellInfo;
|
||||
|
||||
class RigGridBase : public cvf::StructGridInterface
|
||||
{
|
||||
@ -98,7 +99,7 @@ public:
|
||||
virtual bool isCellValid( size_t i, size_t j, size_t k ) const;
|
||||
virtual bool cellIJKNeighbor(size_t i, size_t j, size_t k, FaceType face, size_t* neighborCellIndex ) const;
|
||||
|
||||
cvf::ref<RigGridScalarDataAccess> dataAccessObject(RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const;
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject(const RigActiveCellInfo* activeCellInfo, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const;
|
||||
|
||||
private:
|
||||
std::string m_gridName;
|
||||
|
@ -21,53 +21,52 @@
|
||||
|
||||
#include "cvfLibCore.h"
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigReservoirCellResults.h"
|
||||
#include "RigActiveCellInfo.h"
|
||||
#include "RigGridBase.h"
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigGridScalarDataAccess::RigGridScalarDataAccess(const RigGridBase* grid, bool useGlobalActiveIndex, std::vector<double>* resultValues) :
|
||||
m_grid(grid),
|
||||
m_useGlobalActiveIndex(useGlobalActiveIndex),
|
||||
class RigGridAllCellsScalarDataAccess : public cvf::StructGridScalarDataAccess
|
||||
{
|
||||
public:
|
||||
RigGridAllCellsScalarDataAccess(const RigGridBase* grid, std::vector<double>* resultValues);
|
||||
|
||||
virtual double cellScalar(size_t i, size_t j, size_t k) const;
|
||||
virtual double cellScalar(size_t cellIndex) const;
|
||||
virtual void cellCornerScalars(size_t i, size_t j, size_t k, double scalars[8]) const;
|
||||
virtual double gridPointScalar(size_t i, size_t j, size_t k) const;
|
||||
virtual bool pointScalar(const cvf::Vec3d& p, double* scalarValue) const;
|
||||
|
||||
virtual const cvf::Vec3d* cellVector(size_t i, size_t j, size_t k) const;
|
||||
|
||||
protected:
|
||||
cvf::cref<RigGridBase> m_grid;
|
||||
std::vector<double>* m_resultValues;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigGridAllCellsScalarDataAccess::RigGridAllCellsScalarDataAccess(const RigGridBase* grid, std::vector<double>* resultValues) :
|
||||
m_grid(grid),
|
||||
m_resultValues(resultValues)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RigGridScalarDataAccess> RigGridScalarDataAccess::createDataAccessObject(const RigGridBase* grid, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex)
|
||||
{
|
||||
CVF_ASSERT(grid);
|
||||
CVF_ASSERT(grid->mainGrid());
|
||||
CVF_ASSERT(grid->mainGrid()->results(porosityModel));
|
||||
|
||||
if (!grid || !grid->mainGrid() || !grid->mainGrid()->results(porosityModel))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool useGlobalActiveIndex = grid->mainGrid()->results(porosityModel)->isUsingGlobalActiveIndex(scalarSetIndex);
|
||||
|
||||
std::vector< std::vector<double> > & scalarSetResults = grid->mainGrid()->results(porosityModel)->cellScalarResults(scalarSetIndex);
|
||||
if (timeStepIndex >= scalarSetResults.size())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::vector<double>* resultValues = &(scalarSetResults[timeStepIndex]);
|
||||
|
||||
cvf::ref<RigGridScalarDataAccess> object = new RigGridScalarDataAccess(grid, useGlobalActiveIndex, resultValues);
|
||||
return object;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RigGridScalarDataAccess::cellScalar(size_t i, size_t j, size_t k) const
|
||||
double RigGridAllCellsScalarDataAccess::cellScalar(size_t i, size_t j, size_t k) const
|
||||
{
|
||||
size_t cellIndex = m_grid->cellIndexFromIJK(i, j, k);
|
||||
|
||||
@ -77,27 +76,19 @@ double RigGridScalarDataAccess::cellScalar(size_t i, size_t j, size_t k) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RigGridScalarDataAccess::cellScalar(size_t cellIndex) const
|
||||
double RigGridAllCellsScalarDataAccess::cellScalar(size_t cellIndex) const
|
||||
{
|
||||
if (m_resultValues->size() == 0 ) return HUGE_VAL;
|
||||
|
||||
size_t resultValueIndex = cellIndex;
|
||||
if (m_resultValues->size() <= cellIndex) return HUGE_VAL;
|
||||
|
||||
if (m_useGlobalActiveIndex)
|
||||
{
|
||||
resultValueIndex = m_grid->cell(cellIndex).activeIndexInMatrixModel();
|
||||
if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL;
|
||||
}
|
||||
|
||||
if (m_resultValues->size() <= resultValueIndex) return HUGE_VAL;
|
||||
|
||||
return m_resultValues->at(resultValueIndex);
|
||||
return m_resultValues->at(cellIndex);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RigGridScalarDataAccess::gridPointScalar(size_t i, size_t j, size_t k) const
|
||||
double RigGridAllCellsScalarDataAccess::gridPointScalar(size_t i, size_t j, size_t k) const
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
return 0.0;
|
||||
@ -106,7 +97,7 @@ double RigGridScalarDataAccess::gridPointScalar(size_t i, size_t j, size_t k) co
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigGridScalarDataAccess::cellCornerScalars(size_t i, size_t j, size_t k, double scalars[8]) const
|
||||
void RigGridAllCellsScalarDataAccess::cellCornerScalars(size_t i, size_t j, size_t k, double scalars[8]) const
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
}
|
||||
@ -114,7 +105,7 @@ void RigGridScalarDataAccess::cellCornerScalars(size_t i, size_t j, size_t k, do
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigGridScalarDataAccess::pointScalar(const cvf::Vec3d& p, double* scalarValue) const
|
||||
bool RigGridAllCellsScalarDataAccess::pointScalar(const cvf::Vec3d& p, double* scalarValue) const
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
return false;
|
||||
@ -123,9 +114,134 @@ bool RigGridScalarDataAccess::pointScalar(const cvf::Vec3d& p, double* scalarVal
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const cvf::Vec3d* RigGridScalarDataAccess::cellVector(size_t i, size_t j, size_t k) const
|
||||
const cvf::Vec3d* RigGridAllCellsScalarDataAccess::cellVector(size_t i, size_t j, size_t k) const
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
return new cvf::Vec3d();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RigGridMatrixActiveCellsScalarDataAccess : public RigGridAllCellsScalarDataAccess
|
||||
{
|
||||
public:
|
||||
RigGridMatrixActiveCellsScalarDataAccess(const RigGridBase* grid, std::vector<double>* resultValues, const RigActiveCellInfo* activeCellInfo) :
|
||||
RigGridAllCellsScalarDataAccess(grid, resultValues),
|
||||
m_activeCellInfo(activeCellInfo)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual double cellScalar(size_t cellIndex) const
|
||||
{
|
||||
if (m_resultValues->size() == 0 ) return HUGE_VAL;
|
||||
|
||||
size_t mainGridCellIndex = m_grid->cell(cellIndex).mainGridCellIndex();
|
||||
|
||||
size_t resultValueIndex = m_activeCellInfo->activeIndexInMatrixModel(mainGridCellIndex);
|
||||
if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL;
|
||||
|
||||
if (m_resultValues->size() <= resultValueIndex) return HUGE_VAL;
|
||||
|
||||
return m_resultValues->at(resultValueIndex);
|
||||
}
|
||||
|
||||
protected:
|
||||
const RigActiveCellInfo* m_activeCellInfo;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RigGridFractureActiveCellsScalarDataAccess : public RigGridAllCellsScalarDataAccess
|
||||
{
|
||||
public:
|
||||
RigGridFractureActiveCellsScalarDataAccess(const RigGridBase* grid, std::vector<double>* resultValues, const RigActiveCellInfo* activeCellInfo) :
|
||||
RigGridAllCellsScalarDataAccess(grid, resultValues),
|
||||
m_activeCellInfo(activeCellInfo)
|
||||
{
|
||||
}
|
||||
|
||||
virtual double cellScalar(size_t cellIndex) const
|
||||
{
|
||||
if (m_resultValues->size() == 0 ) return HUGE_VAL;
|
||||
|
||||
size_t mainGridCellIndex = m_grid->cell(cellIndex).mainGridCellIndex();
|
||||
|
||||
size_t resultValueIndex = m_activeCellInfo->activeIndexInFractureModel(mainGridCellIndex);
|
||||
if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL;
|
||||
|
||||
if (m_resultValues->size() <= resultValueIndex) return HUGE_VAL;
|
||||
|
||||
return m_resultValues->at(resultValueIndex);
|
||||
}
|
||||
|
||||
protected:
|
||||
const RigActiveCellInfo* m_activeCellInfo;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> RigGridScalarDataAccessFactory::createDataAccessObject(const RigGridBase* grid,
|
||||
const RigActiveCellInfo* activeCellInfo,
|
||||
RifReaderInterface::PorosityModelResultType porosityModel,
|
||||
size_t timeStepIndex,
|
||||
size_t scalarSetIndex)
|
||||
{
|
||||
CVF_ASSERT(grid);
|
||||
CVF_ASSERT(grid->mainGrid());
|
||||
CVF_ASSERT(grid->mainGrid()->results(porosityModel));
|
||||
CVF_ASSERT(activeCellInfo);
|
||||
|
||||
if (!grid || !grid->mainGrid() || !grid->mainGrid()->results(porosityModel) || !activeCellInfo)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::vector< std::vector<double> > & scalarSetResults = grid->mainGrid()->results(porosityModel)->cellScalarResults(scalarSetIndex);
|
||||
if (timeStepIndex >= scalarSetResults.size())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::vector<double>* resultValues = &(scalarSetResults[timeStepIndex]);
|
||||
|
||||
|
||||
bool useGlobalActiveIndex = grid->mainGrid()->results(porosityModel)->isUsingGlobalActiveIndex(scalarSetIndex);
|
||||
if (useGlobalActiveIndex)
|
||||
{
|
||||
if (porosityModel == RifReaderInterface::MATRIX_RESULTS)
|
||||
{
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> object = new RigGridMatrixActiveCellsScalarDataAccess(grid, resultValues, activeCellInfo);
|
||||
return object;
|
||||
}
|
||||
else
|
||||
{
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> object = new RigGridFractureActiveCellsScalarDataAccess(grid, resultValues, activeCellInfo);
|
||||
return object;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> object = new RigGridAllCellsScalarDataAccess(grid, resultValues);
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,32 +20,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "cvfStructGridScalarDataAccess.h"
|
||||
#include "RigGridBase.h"
|
||||
#include "RifReaderInterface.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RigGridScalarDataAccess : public cvf::StructGridScalarDataAccess
|
||||
class RigActiveCellInfo;
|
||||
class RigGridBase;
|
||||
|
||||
class RigGridScalarDataAccessFactory
|
||||
{
|
||||
private:
|
||||
RigGridScalarDataAccess(const RigGridBase* grid, bool useGlobalActiveIndex, std::vector<double>* resultValues);
|
||||
|
||||
public:
|
||||
static cvf::ref<RigGridScalarDataAccess> createDataAccessObject(const RigGridBase* grid, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex);
|
||||
static cvf::ref<cvf::StructGridScalarDataAccess> createDataAccessObject(const RigGridBase* grid,
|
||||
const RigActiveCellInfo* activeCellInfo,
|
||||
RifReaderInterface::PorosityModelResultType porosityModel,
|
||||
size_t timeStepIndex,
|
||||
size_t scalarSetIndex);
|
||||
|
||||
virtual double cellScalar(size_t i, size_t j, size_t k) const;
|
||||
virtual double cellScalar(size_t cellIndex) const;
|
||||
virtual void cellCornerScalars(size_t i, size_t j, size_t k, double scalars[8]) const;
|
||||
virtual double gridPointScalar(size_t i, size_t j, size_t k) const;
|
||||
virtual bool pointScalar(const cvf::Vec3d& p, double* scalarValue) const;
|
||||
|
||||
virtual const cvf::Vec3d* cellVector(size_t i, size_t j, size_t k) const;
|
||||
|
||||
private:
|
||||
cvf::cref<RigGridBase> m_grid;
|
||||
bool m_useGlobalActiveIndex;
|
||||
std::vector<double>* m_resultValues;
|
||||
};
|
||||
|
||||
|
||||
|
@ -310,3 +310,11 @@ RigActiveCellInfo* RigReservoir::activeCellInfo()
|
||||
{
|
||||
return &m_activeCellInfo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RigActiveCellInfo* RigReservoir::activeCellInfo() const
|
||||
{
|
||||
return &m_activeCellInfo;
|
||||
}
|
||||
|
@ -52,7 +52,8 @@ public:
|
||||
RigCell& cellFromWellResultCell(const RigWellResultCell& wellResultCell);
|
||||
bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const;
|
||||
|
||||
RigActiveCellInfo* activeCellInfo();
|
||||
RigActiveCellInfo* activeCellInfo();
|
||||
const RigActiveCellInfo* activeCellInfo() const;
|
||||
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user