From 57494c4bfe65a0e65f5e0c5ca48e14a1877ad1cf Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 6 Aug 2014 15:14:01 +0200 Subject: [PATCH] Added ResultAccessObject for combined transmissibility --- .../ReservoirDataModel/CMakeLists_files.cmake | 2 + .../RigCellFaceResultAccessObject.cpp | 2 + .../RigCombTransResultAccessObject.cpp | 157 ++++++++++++++++++ .../RigCombTransResultAccessObject.h | 48 ++++++ .../ReservoirDataModel/RigGridBase.h | 1 - .../RigResultAccessObjectFactory.cpp | 142 ++++++++++++++++ .../RigResultAccessObjectFactory.h | 31 +++- 7 files changed, 373 insertions(+), 10 deletions(-) create mode 100644 ApplicationCode/ReservoirDataModel/RigCombTransResultAccessObject.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigCombTransResultAccessObject.h diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 154b885bd0..123e156828 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -15,6 +15,7 @@ ${CEE_CURRENT_LIST_DIR}RigResultAccessObjectFactory.h ${CEE_CURRENT_LIST_DIR}RigAllGridCellsResultAccessObject.h ${CEE_CURRENT_LIST_DIR}RigActiveCellsResultAccessObject.h ${CEE_CURRENT_LIST_DIR}RigCellFaceResultAccessObject.h +${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessObject.h ${CEE_CURRENT_LIST_DIR}RigLocalGrid.h ${CEE_CURRENT_LIST_DIR}RigMainGrid.h ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.h @@ -39,6 +40,7 @@ ${CEE_CURRENT_LIST_DIR}RigResultAccessObjectFactory.cpp ${CEE_CURRENT_LIST_DIR}RigAllGridCellsResultAccessObject.cpp ${CEE_CURRENT_LIST_DIR}RigActiveCellsResultAccessObject.cpp ${CEE_CURRENT_LIST_DIR}RigCellFaceResultAccessObject.cpp +${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessObject.cpp ${CEE_CURRENT_LIST_DIR}RigLocalGrid.cpp ${CEE_CURRENT_LIST_DIR}RigMainGrid.cpp ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceResultAccessObject.cpp b/ApplicationCode/ReservoirDataModel/RigCellFaceResultAccessObject.cpp index 808d8b7708..86b8bbbfaa 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellFaceResultAccessObject.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceResultAccessObject.cpp @@ -18,6 +18,8 @@ #include "RigCellFaceResultAccessObject.h" +#include + //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessObject.cpp b/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessObject.cpp new file mode 100644 index 0000000000..60786a606a --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessObject.cpp @@ -0,0 +1,157 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA, Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigCombTransResultAccessObject.h" + +#include "RigGridBase.h" + +#include + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCombTransResultAccessObject::RigCombTransResultAccessObject(const RigGridBase* grid, const QString& resultName) + : m_grid(grid), + m_resultName(resultName) +{ + m_resultAccessObjects.resize(6); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCombTransResultAccessObject::setDataAccessObjectForFace(cvf::StructGridInterface::FaceType faceId, RigResultAccessObject* resultAccessObject) +{ + m_resultAccessObjects[faceId] = resultAccessObject; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCombTransResultAccessObject::cellScalar(size_t localCellIndex) const +{ + + // TODO: How to handle when we get here? + CVF_ASSERT(false); + + return cvf::UNDEFINED_DOUBLE; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCombTransResultAccessObject::cellFaceScalar(size_t localCellIndex, cvf::StructGridInterface::FaceType faceId) const +{ + switch (faceId) + { + case cvf::StructGridInterface::POS_I: + { + const RigResultAccessObject* resultAccessObj = m_resultAccessObjects.at(cvf::StructGridInterface::POS_I); + if (resultAccessObj) + { + return resultAccessObj->cellScalar(localCellIndex); + } + } + break; + case cvf::StructGridInterface::NEG_I: + { + const RigResultAccessObject* resultAccessObj = m_resultAccessObjects.at(cvf::StructGridInterface::POS_I); + if (resultAccessObj) + { + size_t i, j, k, neighborGridCellIdx; + m_grid->ijkFromCellIndex(localCellIndex, &i, &j, &k); + + if (m_grid->cellIJKNeighbor(i, j, k, cvf::StructGridInterface::NEG_I, &neighborGridCellIdx)) + { + return resultAccessObj->cellScalar(neighborGridCellIdx); + } + } + } + break; + case cvf::StructGridInterface::POS_J: + { + const RigResultAccessObject* resultAccessObj = m_resultAccessObjects.at(cvf::StructGridInterface::POS_J); + if (resultAccessObj) + { + return resultAccessObj->cellScalar(localCellIndex); + } + } + break; + case cvf::StructGridInterface::NEG_J: + { + const RigResultAccessObject* resultAccessObj = m_resultAccessObjects.at(cvf::StructGridInterface::POS_J); + if (resultAccessObj) + { + size_t i, j, k, neighborGridCellIdx; + m_grid->ijkFromCellIndex(localCellIndex, &i, &j, &k); + + if (m_grid->cellIJKNeighbor(i, j, k, cvf::StructGridInterface::NEG_J, &neighborGridCellIdx)) + { + return resultAccessObj->cellScalar(neighborGridCellIdx); + } + } + } + break; + case cvf::StructGridInterface::POS_K: + { + const RigResultAccessObject* resultAccessObj = m_resultAccessObjects.at(cvf::StructGridInterface::POS_K); + if (resultAccessObj) + { + return resultAccessObj->cellScalar(localCellIndex); + } + } + break; + case cvf::StructGridInterface::NEG_K: + { + const RigResultAccessObject* resultAccessObj = m_resultAccessObjects.at(cvf::StructGridInterface::POS_K); + if (resultAccessObj) + { + size_t i, j, k, neighborGridCellIdx; + m_grid->ijkFromCellIndex(localCellIndex, &i, &j, &k); + + if (m_grid->cellIJKNeighbor(i, j, k, cvf::StructGridInterface::NEG_K, &neighborGridCellIdx)) + { + return resultAccessObj->cellScalar(neighborGridCellIdx); + } + } + } + break; + } + + return HUGE_VAL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigCombTransResultAccessObject::resultName() const +{ + return m_resultName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCombTransResultAccessObject::setCellScalar(size_t localCellIndex, double scalarValue) +{ + // TODO: How to handle when we get here? + CVF_ASSERT(false); + +} + diff --git a/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessObject.h b/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessObject.h new file mode 100644 index 0000000000..19e27b487a --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessObject.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA, Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RigResultAccessObject.h" + +#include "cvfCollection.h" + +class RigGridBase; + + +//================================================================================================== +/// +//================================================================================================== +class RigCombTransResultAccessObject : public RigResultAccessObject +{ +public: + RigCombTransResultAccessObject(const RigGridBase* grid, const QString& resultName); + + void setDataAccessObjectForFace(cvf::StructGridInterface::FaceType faceId, RigResultAccessObject* resultAccessObject); + + virtual double cellScalar(size_t localCellIndex) const; + virtual double cellFaceScalar(size_t localCellIndex, cvf::StructGridInterface::FaceType faceId) const; + virtual QString resultName() const; + virtual void setCellScalar(size_t localCellIndex, double scalarValue); + +private: + cvf::Collection m_resultAccessObjects; + + const RigGridBase* m_grid; + QString m_resultName; +}; diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.h b/ApplicationCode/ReservoirDataModel/RigGridBase.h index cc061c18fa..a8285ad227 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.h @@ -37,7 +37,6 @@ class RigMainGrid; class RigCell; -class RigGridScalarDataAccess; class RigActiveCellInfo; class RigGridBase : public cvf::StructGridInterface diff --git a/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.cpp b/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.cpp index d093fca77b..052aa35a6a 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.cpp +++ b/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.cpp @@ -18,6 +18,10 @@ #include "RigResultAccessObjectFactory.h" +#include "RigResultAccessObject.h" +#include "RigActiveCellsResultAccessObject.h" +#include "RigAllGridCellsResultAccessObject.h" + #include "cvfLibCore.h" #include "cvfBase.h" #include "cvfObject.h" @@ -29,6 +33,84 @@ #include "RigGridBase.h" #include "RigCaseData.h" #include +#include "RigCombTransResultAccessObject.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RigResultAccessObjectFactory::createNativeDataAccessObject(RigCaseData* eclipseCase, + size_t gridIndex, + RifReaderInterface::PorosityModelResultType porosityModel, + size_t timeStepIndex, + QString& uiResultName) +{ + CVF_ASSERT(gridIndex < eclipseCase->gridCount()); + CVF_ASSERT(eclipseCase); + CVF_ASSERT(eclipseCase->results(porosityModel)); + CVF_ASSERT(eclipseCase->activeCellInfo(porosityModel)); + + RigGridBase *grid = eclipseCase->grid(gridIndex); + + if (!eclipseCase || !eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo(porosityModel)) + { + return NULL; + } + + size_t scalarSetIndex = eclipseCase->results(porosityModel)->findScalarResultIndex(uiResultName); + if (scalarSetIndex == cvf::UNDEFINED_SIZE_T) + { + return NULL; + } + + std::vector< std::vector >& scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(scalarSetIndex); + + // A generated result with a generated results for a subset of time steps, will end up with a result container with less entries than time steps + // See RiaSetGridProperty command in RiaPropertyDataCommands + // + // Some functions requires a valid data access object to be present, these might be rewritten to avoid this dummy object always returning HUGE_VAL + if (timeStepIndex >= scalarSetResults.size()) + { + return NULL; + } + + std::vector* resultValues = NULL; + if (timeStepIndex < scalarSetResults.size()) + { + resultValues = &(scalarSetResults[timeStepIndex]); + } + + bool useGlobalActiveIndex = eclipseCase->results(porosityModel)->isUsingGlobalActiveIndex(scalarSetIndex); + if (useGlobalActiveIndex) + { + cvf::ref object = new RigActiveCellsResultAccessObject(grid, resultValues, eclipseCase->activeCellInfo(porosityModel), uiResultName); + return object; + } + else + { + cvf::ref object = new RigAllGridCellsResultAccessObject(grid, resultValues, uiResultName); + return object; + } +} + + + + + + + + + + +//-------------------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------------------- +// Rest of this file is to be deleted +//-------------------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------------------------- /// @@ -196,3 +278,63 @@ cvf::ref RigResultAccessObjectFactory::TO_BE_DE } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RigResultAccessObjectFactory::createResultAccessObject(RigCaseData* eclipseCase, + size_t gridIndex, + RifReaderInterface::PorosityModelResultType porosityModel, + size_t timeStepIndex, + QString& uiResultName) +{ + CVF_ASSERT(gridIndex < eclipseCase->gridCount()); + CVF_ASSERT(eclipseCase); + CVF_ASSERT(eclipseCase->results(porosityModel)); + CVF_ASSERT(eclipseCase->activeCellInfo(porosityModel)); + + RigGridBase* grid = eclipseCase->grid(gridIndex); + + // Ternary + if (uiResultName == RimDefines::ternarySaturationResultName()) + { + return NULL; + } + else if (uiResultName == RimDefines::combinedTransmissibilityResultName()) + { + // TODO + // Taken from RivTransmissibilityColorMapper::updateCombinedTransmissibilityTextureCoordinates + // + + cvf::ref cellFaceAccessObject = new RigCombTransResultAccessObject(grid, uiResultName); + + { + cvf::ref nativeAccessObject = RigResultAccessObjectFactory::createNativeDataAccessObject(eclipseCase, gridIndex, porosityModel, timeStepIndex, QString("TRANX")); + if (nativeAccessObject.notNull()) + { + cellFaceAccessObject->setDataAccessObjectForFace(cvf::StructGridInterface::POS_I, nativeAccessObject.p()); + } + } + + { + cvf::ref nativeAccessObject = RigResultAccessObjectFactory::createNativeDataAccessObject(eclipseCase, gridIndex, porosityModel, timeStepIndex, QString("TRANY")); + if (nativeAccessObject.notNull()) + { + cellFaceAccessObject->setDataAccessObjectForFace(cvf::StructGridInterface::POS_J, nativeAccessObject.p()); + } + } + + { + cvf::ref nativeAccessObject = RigResultAccessObjectFactory::createNativeDataAccessObject(eclipseCase, gridIndex, porosityModel, timeStepIndex, QString("TRANZ")); + if (nativeAccessObject.notNull()) + { + cellFaceAccessObject->setDataAccessObjectForFace(cvf::StructGridInterface::POS_K, nativeAccessObject.p()); + } + } + + return cellFaceAccessObject; + } + + + return NULL; +} + diff --git a/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.h b/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.h index b50adc5240..aa54258936 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.h +++ b/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.h @@ -24,24 +24,37 @@ class RigActiveCellInfo; class RigGridBase; +class RigResultAccessObject; class RigResultAccessObjectFactory { public: - - - - - + static cvf::ref + createResultAccessObject(RigCaseData* eclipseCase, + size_t gridIndex, + RifReaderInterface::PorosityModelResultType porosityModel, + size_t timeStepIndex, + QString& uiResultName); // TO BE DELETED static cvf::ref TO_BE_DELETED_createNativeDataAccessObject(RigCaseData* eclipseCase, - size_t gridIndex, - RifReaderInterface::PorosityModelResultType porosityModel, - size_t timeStepIndex, - size_t scalarSetIndex); + size_t gridIndex, + RifReaderInterface::PorosityModelResultType porosityModel, + size_t timeStepIndex, + size_t scalarSetIndex); + + +private: + static cvf::ref + createNativeDataAccessObject(RigCaseData* eclipseCase, + size_t gridIndex, + RifReaderInterface::PorosityModelResultType porosityModel, + size_t timeStepIndex, + QString& resultName); + + };