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;
|
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())
|
if (dataAccessObject.isNull())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -119,7 +119,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn
|
|||||||
if (matrixActiveIndex != -1)
|
if (matrixActiveIndex != -1)
|
||||||
{
|
{
|
||||||
cell.setActiveIndexInMatrixModel(matrixActiveStartIndex + matrixActiveIndex);
|
cell.setActiveIndexInMatrixModel(matrixActiveStartIndex + matrixActiveIndex);
|
||||||
activeCellInfo->setActiveIndexInMatrixModel(localCellIdx, matrixActiveStartIndex + matrixActiveIndex);
|
activeCellInfo->setActiveIndexInMatrixModel(cellStartIndex + localCellIdx, matrixActiveStartIndex + matrixActiveIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -130,7 +130,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn
|
|||||||
if (fractureActiveIndex != -1)
|
if (fractureActiveIndex != -1)
|
||||||
{
|
{
|
||||||
cell.setActiveIndexInFractureModel(fractureActiveStartIndex + fractureActiveIndex);
|
cell.setActiveIndexInFractureModel(fractureActiveStartIndex + fractureActiveIndex);
|
||||||
activeCellInfo->setActiveIndexInFractureModel(localCellIdx, fractureActiveStartIndex + fractureActiveIndex);
|
activeCellInfo->setActiveIndexInFractureModel(cellStartIndex + localCellIdx, fractureActiveStartIndex + fractureActiveIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "RimCellEdgeResultSlot.h"
|
#include "RimCellEdgeResultSlot.h"
|
||||||
#include "RigGridScalarDataAccess.h"
|
#include "RigGridScalarDataAccess.h"
|
||||||
#include "RigReservoirCellResults.h"
|
#include "RigReservoirCellResults.h"
|
||||||
|
#include "RigReservoir.h"
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -221,7 +222,10 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
|||||||
if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0;
|
if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0;
|
||||||
|
|
||||||
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
|
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;
|
if (dataAccessObject.isNull()) return;
|
||||||
|
|
||||||
// Outer surface
|
// Outer surface
|
||||||
|
@ -246,10 +246,13 @@ void RivReservoirViewPartMgr::createGeometry(ReservoirGeometryCacheType geometry
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, ReservoirGeometryCacheType geometryType, RigGridBase* grid, size_t gridIdx)
|
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)
|
switch (geometryType)
|
||||||
{
|
{
|
||||||
case ACTIVE:
|
case ACTIVE:
|
||||||
computeNativeVisibility(cellVisibility, grid, false, false, true, m_reservoirView->showMainGrid() );
|
computeNativeVisibility(cellVisibility, grid, activeCellInfo, false, false, true, m_reservoirView->showMainGrid() );
|
||||||
break;
|
break;
|
||||||
case ALL_WELL_CELLS:
|
case ALL_WELL_CELLS:
|
||||||
computeAllWellCellsVisibility(cellVisibility, grid);
|
computeAllWellCellsVisibility(cellVisibility, grid);
|
||||||
@ -287,7 +290,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INACTIVE:
|
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;
|
break;
|
||||||
case RANGE_FILTERED:
|
case RANGE_FILTERED:
|
||||||
{
|
{
|
||||||
@ -460,7 +463,7 @@ void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameInd
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Evaluate visibility based on cell state
|
/// 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 invalidCellsIsVisible,
|
||||||
bool inactiveCellsIsVisible,
|
bool inactiveCellsIsVisible,
|
||||||
bool activeCellsIsVisible,
|
bool activeCellsIsVisible,
|
||||||
@ -468,16 +471,18 @@ void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisib
|
|||||||
{
|
{
|
||||||
CVF_ASSERT(cellVisibility != NULL);
|
CVF_ASSERT(cellVisibility != NULL);
|
||||||
CVF_ASSERT(grid != NULL);
|
CVF_ASSERT(grid != NULL);
|
||||||
|
CVF_ASSERT(activeCellInfo != NULL);
|
||||||
cellVisibility->resize(grid->cellCount());
|
cellVisibility->resize(grid->cellCount());
|
||||||
|
|
||||||
#pragma omp parallel for
|
#pragma omp parallel for
|
||||||
for (int cellIndex = 0; cellIndex < static_cast<int>(grid->cellCount()); cellIndex++)
|
for (int cellIndex = 0; cellIndex < static_cast<int>(grid->cellCount()); cellIndex++)
|
||||||
{
|
{
|
||||||
const RigCell& cell = grid->cell(cellIndex);
|
const RigCell& cell = grid->cell(cellIndex);
|
||||||
|
size_t globalCellIndex = cell.mainGridCellIndex();
|
||||||
|
|
||||||
if ( !invalidCellsIsVisible && cell.isInvalid()
|
if ( !invalidCellsIsVisible && cell.isInvalid()
|
||||||
|| !inactiveCellsIsVisible && !cell.isActiveInMatrixModel()
|
|| !inactiveCellsIsVisible && !activeCellInfo->isActiveInMatrixModel(globalCellIndex)
|
||||||
|| !activeCellsIsVisible && cell.isActiveInMatrixModel()
|
|| !activeCellsIsVisible && activeCellInfo->isActiveInMatrixModel(globalCellIndex)
|
||||||
|| mainGridIsVisible && (cell.subGrid() != NULL)
|
|| mainGridIsVisible && (cell.subGrid() != NULL)
|
||||||
|| cell.isWellCell()
|
|| cell.isWellCell()
|
||||||
)
|
)
|
||||||
@ -600,7 +605,9 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis
|
|||||||
const RimCellFilter::FilterModeType filterType = (*pfIt)->filterMode();
|
const RimCellFilter::FilterModeType filterType = (*pfIt)->filterMode();
|
||||||
|
|
||||||
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel((*pfIt)->resultDefinition()->porosityModel());
|
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());
|
CVF_ASSERT(dataAccessObject.notNull());
|
||||||
|
|
||||||
#pragma omp parallel for schedule(dynamic)
|
#pragma omp parallel for schedule(dynamic)
|
||||||
|
@ -28,6 +28,7 @@ class RimReservoirView;
|
|||||||
class RigGridBase;
|
class RigGridBase;
|
||||||
class RimCellRangeFilterCollection;
|
class RimCellRangeFilterCollection;
|
||||||
class RimCellPropertyFilterCollection;
|
class RimCellPropertyFilterCollection;
|
||||||
|
class RigActiveCellInfo;
|
||||||
|
|
||||||
class RivReservoirViewPartMgr: public cvf::Object
|
class RivReservoirViewPartMgr: public cvf::Object
|
||||||
{
|
{
|
||||||
@ -77,7 +78,7 @@ private:
|
|||||||
void clearGeometryCache(ReservoirGeometryCacheType geomType);
|
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 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 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 );
|
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 RigReservoir* reservoir = m_reservoir->reservoirData();
|
||||||
const RigGridBase* grid = reservoir->grid(gridIndex);
|
const RigGridBase* grid = reservoir->grid(gridIndex);
|
||||||
|
const RigActiveCellInfo* activeCellInfo = reservoir->activeCellInfo();
|
||||||
|
|
||||||
if (this->cellResult()->hasResult())
|
if (this->cellResult()->hasResult())
|
||||||
{
|
{
|
||||||
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel());
|
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())
|
if (dataAccessObject.notNull())
|
||||||
{
|
{
|
||||||
double scalarValue = dataAccessObject->cellScalar(cellIndex);
|
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
|
// Cell edge results are static, results are loaded for first time step only
|
||||||
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel());
|
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())
|
if (dataAccessObject.notNull())
|
||||||
{
|
{
|
||||||
double scalarValue = dataAccessObject->cellScalar(cellIndex);
|
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 &&
|
if (timeStepIndex != cvf::UNDEFINED_SIZE_T &&
|
||||||
scalarSetIndex != 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;
|
return dataAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
class RigMainGrid;
|
class RigMainGrid;
|
||||||
class RigCell;
|
class RigCell;
|
||||||
class RigGridScalarDataAccess;
|
class RigGridScalarDataAccess;
|
||||||
|
class RigActiveCellInfo;
|
||||||
|
|
||||||
class RigGridBase : public cvf::StructGridInterface
|
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 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;
|
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:
|
private:
|
||||||
std::string m_gridName;
|
std::string m_gridName;
|
||||||
|
@ -21,53 +21,52 @@
|
|||||||
|
|
||||||
#include "cvfLibCore.h"
|
#include "cvfLibCore.h"
|
||||||
#include "cvfBase.h"
|
#include "cvfBase.h"
|
||||||
|
#include "cvfObject.h"
|
||||||
#include "cvfAssert.h"
|
#include "cvfAssert.h"
|
||||||
|
|
||||||
#include "RigMainGrid.h"
|
#include "RigMainGrid.h"
|
||||||
#include "RigReservoirCellResults.h"
|
#include "RigReservoirCellResults.h"
|
||||||
|
#include "RigActiveCellInfo.h"
|
||||||
|
#include "RigGridBase.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RigGridScalarDataAccess::RigGridScalarDataAccess(const RigGridBase* grid, bool useGlobalActiveIndex, std::vector<double>* resultValues) :
|
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_grid(grid),
|
||||||
m_useGlobalActiveIndex(useGlobalActiveIndex),
|
|
||||||
m_resultValues(resultValues)
|
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);
|
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;
|
if (m_resultValues->size() == 0 ) return HUGE_VAL;
|
||||||
|
|
||||||
size_t resultValueIndex = cellIndex;
|
if (m_resultValues->size() <= cellIndex) return HUGE_VAL;
|
||||||
|
|
||||||
if (m_useGlobalActiveIndex)
|
return m_resultValues->at(cellIndex);
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
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);
|
CVF_ASSERT(false);
|
||||||
return 0.0;
|
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);
|
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);
|
CVF_ASSERT(false);
|
||||||
return 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);
|
CVF_ASSERT(false);
|
||||||
return new cvf::Vec3d();
|
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
|
#pragma once
|
||||||
|
|
||||||
#include "cvfStructGridScalarDataAccess.h"
|
#include "cvfStructGridScalarDataAccess.h"
|
||||||
#include "RigGridBase.h"
|
|
||||||
#include "RifReaderInterface.h"
|
#include "RifReaderInterface.h"
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
class RigActiveCellInfo;
|
||||||
///
|
class RigGridBase;
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
class RigGridScalarDataAccess : public cvf::StructGridScalarDataAccess
|
class RigGridScalarDataAccessFactory
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
RigGridScalarDataAccess(const RigGridBase* grid, bool useGlobalActiveIndex, std::vector<double>* resultValues);
|
|
||||||
|
|
||||||
public:
|
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;
|
return &m_activeCellInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
const RigActiveCellInfo* RigReservoir::activeCellInfo() const
|
||||||
|
{
|
||||||
|
return &m_activeCellInfo;
|
||||||
|
}
|
||||||
|
@ -53,6 +53,7 @@ public:
|
|||||||
bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const;
|
bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const;
|
||||||
|
|
||||||
RigActiveCellInfo* activeCellInfo();
|
RigActiveCellInfo* activeCellInfo();
|
||||||
|
const RigActiveCellInfo* activeCellInfo() const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user