From 28a0e1107c87e8e91b4fa1c54b25192ff4864e41 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 9 Dec 2015 09:17:13 +0100 Subject: [PATCH] Improved result accessor factory Moved clamping of time step to zero for static results into factory --- .../RivCrossSectionPartMgr.cpp | 11 ++----- .../RivReservoirViewPartMgr.cpp | 11 +------ .../RivTextureCoordsCreator.cpp | 8 +---- .../RimWellLogExtractionCurve.cpp | 9 ++---- .../RigResultAccessorFactory.cpp | 31 ++++++++++++++++++- .../RigResultAccessorFactory.h | 12 +++++-- 6 files changed, 46 insertions(+), 36 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivCrossSectionPartMgr.cpp b/ApplicationCode/ModelVisualization/RivCrossSectionPartMgr.cpp index 4c4b3a83b2..3aa569149e 100644 --- a/ApplicationCode/ModelVisualization/RivCrossSectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivCrossSectionPartMgr.cpp @@ -126,17 +126,10 @@ void RivCrossSectionPartMgr::updateCellResultColor(size_t timeStepIndex) } else { - size_t adjustedTimeStepIndex = timeStepIndex; - if (cellResultColors->hasStaticResult()) - { - adjustedTimeStepIndex = 0; - } - resultAccessor = RigResultAccessorFactory::createResultAccessor(cellResultColors->reservoirView()->eclipseCase()->reservoirData(), 0, - RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultColors->porosityModel()), - adjustedTimeStepIndex, - cellResultColors->resultVariable()); + timeStepIndex, + cellResultColors); } RivCrossSectionPartMgr::calculateEclipseTextureCoordinates(m_crossSectionFacesTextureCoords.p(), diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index 762ba1d1a8..5714221d55 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -785,20 +785,11 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis const double lowerBound = propertyFilter->lowerBound(); const double upperBound = propertyFilter->upperBound(); - size_t adjustedTimeStepIndex = timeStepIndex; - - // Set time step to zero for static results - if (propertyFilter->resultDefinition()->hasStaticResult()) - { - adjustedTimeStepIndex = 0; - } - const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode(); - RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(propertyFilter->resultDefinition()->porosityModel()); RigCaseData* eclipseCase = propFilterColl->reservoirView()->eclipseCase()->reservoirData(); - cvf::ref resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, grid->gridIndex(), porosityModel, adjustedTimeStepIndex, propertyFilter->resultDefinition->resultVariable(), propertyFilter->resultDefinition->resultType()); + cvf::ref resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, grid->gridIndex(), timeStepIndex, propertyFilter->resultDefinition()); CVF_ASSERT(resultAccessor.notNull()); //#pragma omp parallel for schedule(dynamic) diff --git a/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp b/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp index 4683af0e17..91dbabe2db 100644 --- a/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp +++ b/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp @@ -39,13 +39,7 @@ RivTextureCoordsCreator::RivTextureCoordsCreator(RimEclipseCellColors* cellResul m_quadMapper = quadMapper; CVF_ASSERT(quadMapper && eclipseCase ); - size_t resTimeStepIdx = timeStepIndex; - - if (cellResultColors->hasStaticResult()) resTimeStepIdx = 0; - - RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultColors->porosityModel()); - - m_resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, cellResultColors->resultVariable()); + m_resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, timeStepIndex, cellResultColors); cvf::ref pipeInCellEval = new RigPipeInCellEvaluator(cellResultColors->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex), eclipseCase->gridCellToWellIndex(gridIndex)); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 1d471b8de7..6e9ada5311 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -213,14 +213,11 @@ void RimWellLogExtractionCurve::updatePlotData() tvDepthValues = eclExtractor->trueVerticalDepth(); } - RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_eclipseResultDefinition->porosityModel()); - m_eclipseResultDefinition->loadResult(); - cvf::ref resAcc = RigResultAccessorFactory::createResultAccessor( - eclipseCase->reservoirData(), 0, - porosityModel, + eclipseCase->reservoirData(), + 0, m_timeStep, - m_eclipseResultDefinition->resultVariable()); + m_eclipseResultDefinition); if (resAcc.notNull()) { diff --git a/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp b/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp index 5377028d91..958fe7f689 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp +++ b/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp @@ -30,6 +30,8 @@ #include "RigMainGrid.h" #include "RigResultAccessor.h" +#include "RimEclipseResultDefinition.h" + #include "cvfAssert.h" #include "cvfBase.h" #include "cvfLibCore.h" @@ -145,7 +147,34 @@ cvf::ref RigResultAccessorFactory::createResultAccessor(RigCa return NULL; } - return createResultAccessor(eclipseCase, gridIndex, porosityModel, timeStepIndex, scalarSetIndex); + size_t adjustedTimeStepIndex = timeStepIndex; + if (resultType == RimDefines::STATIC_NATIVE) + { + adjustedTimeStepIndex = 0; + } + + return createResultAccessor(eclipseCase, gridIndex, porosityModel, adjustedTimeStepIndex, scalarSetIndex); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RigResultAccessorFactory::createResultAccessor(RigCaseData* eclipseCase, size_t gridIndex, size_t timeStepIndex, RimEclipseResultDefinition* resultDefinition) +{ + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(resultDefinition->porosityModel()); + resultDefinition->loadResult(); + + size_t adjustedTimeStepIndex = timeStepIndex; + if (resultDefinition->hasStaticResult()) + { + adjustedTimeStepIndex = 0; + } + + return RigResultAccessorFactory::createResultAccessor( + eclipseCase, 0, + porosityModel, + adjustedTimeStepIndex, + resultDefinition->resultVariable()); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.h b/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.h index aec039f3fe..b85440b573 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.h +++ b/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.h @@ -21,14 +21,23 @@ #include "RifReaderInterface.h" #include "RigResultAccessor.h" + #include "RimDefines.h" class RigActiveCellInfo; class RigGridBase; +class RimEclipseResultDefinition; + class RigResultAccessorFactory { public: + static cvf::ref + createResultAccessor(RigCaseData* eclipseCase, + size_t gridIndex, + size_t timeStepIndex, + RimEclipseResultDefinition* resultDefinition); + static cvf::ref createResultAccessor(RigCaseData* eclipseCase, size_t gridIndex, @@ -51,8 +60,6 @@ public: size_t timeStepIndex, size_t resultIndex); - - private: static cvf::ref createNativeResultAccessor(RigCaseData* eclipseCase, @@ -61,7 +68,6 @@ private: size_t timeStepIndex, const QString& resultName); - };