From cb8edaffdef459ebe7257abd16715630f9827a66 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 6 Aug 2014 13:47:15 +0200 Subject: [PATCH] Added data access objects for native results --- .../ReservoirDataModel/CMakeLists_files.cmake | 4 + .../RigActiveCellsResultAccessObject.cpp | 76 +++++++++++++++++ .../RigActiveCellsResultAccessObject.h | 83 +++++++++++++++++++ .../RigAllGridCellsResultAccessObject.cpp | 72 ++++++++++++++++ .../RigAllGridCellsResultAccessObject.h | 81 ++++++++++++++++++ .../RigResultAccessObject.h | 5 +- .../RigResultAccessObjectFactory.cpp | 2 +- .../RigResultAccessObjectFactory.h | 2 +- 8 files changed, 322 insertions(+), 3 deletions(-) create mode 100644 ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessObject.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessObject.h create mode 100644 ApplicationCode/ReservoirDataModel/RigAllGridCellsResultAccessObject.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigAllGridCellsResultAccessObject.h diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 66f639fd08..31552802cb 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -12,6 +12,8 @@ ${CEE_CURRENT_LIST_DIR}RigGridBase.h ${CEE_CURRENT_LIST_DIR}RigGridManager.h ${CEE_CURRENT_LIST_DIR}RigResultAccessObject.h ${CEE_CURRENT_LIST_DIR}RigResultAccessObjectFactory.h +${CEE_CURRENT_LIST_DIR}RigAllGridCellsResultAccessObject.h +${CEE_CURRENT_LIST_DIR}RigActiveCellsResultAccessObject.h ${CEE_CURRENT_LIST_DIR}RigLocalGrid.h ${CEE_CURRENT_LIST_DIR}RigMainGrid.h ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.h @@ -33,6 +35,8 @@ ${CEE_CURRENT_LIST_DIR}RigGridBase.cpp ${CEE_CURRENT_LIST_DIR}RigGridManager.cpp ${CEE_CURRENT_LIST_DIR}RigResultAccessObject.cpp ${CEE_CURRENT_LIST_DIR}RigResultAccessObjectFactory.cpp +${CEE_CURRENT_LIST_DIR}RigAllGridCellsResultAccessObject.cpp +${CEE_CURRENT_LIST_DIR}RigActiveCellsResultAccessObject.cpp ${CEE_CURRENT_LIST_DIR}RigLocalGrid.cpp ${CEE_CURRENT_LIST_DIR}RigMainGrid.cpp ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessObject.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessObject.cpp new file mode 100644 index 0000000000..3cfddaf58f --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessObject.cpp @@ -0,0 +1,76 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RigActiveCellsResultAccessObject.h" + +#include "RigGridBase.h" +#include "RigActiveCellInfo.h" + +RigActiveCellsResultAccessObject::RigActiveCellsResultAccessObject(const RigGridBase* grid, std::vector* reservoirResultValues, const RigActiveCellInfo* activeCellInfo, const QString& resultName) + : m_grid(grid), + m_reservoirResultValues(reservoirResultValues), + m_activeCellInfo(activeCellInfo), + m_resultName(resultName) +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigActiveCellsResultAccessObject::cellScalar(size_t localCellIndex) const +{ + if (m_reservoirResultValues == NULL || m_reservoirResultValues->size() == 0 ) return HUGE_VAL; + + size_t globalGridCellIndex = m_grid->globalGridCellIndex(localCellIndex); + size_t resultValueIndex = m_activeCellInfo->cellResultIndex(globalGridCellIndex); + if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL; + + CVF_TIGHT_ASSERT(resultValueIndex < m_reservoirResultValues->size()); + + return m_reservoirResultValues->at(resultValueIndex); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigActiveCellsResultAccessObject::cellFaceScalar(size_t localCellIndex, cvf::StructGridInterface::FaceType faceId) const +{ + return cellScalar(localCellIndex); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigActiveCellsResultAccessObject::resultName() const +{ + return m_resultName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellsResultAccessObject::setCellScalar(size_t localCellIndex, double scalarValue) +{ + size_t globalGridCellIndex = m_grid->globalGridCellIndex(localCellIndex); + size_t resultValueIndex = m_activeCellInfo->cellResultIndex(globalGridCellIndex); + + CVF_TIGHT_ASSERT(m_reservoirResultValues != NULL && resultValueIndex < m_reservoirResultValues->size()); + + (*m_reservoirResultValues)[resultValueIndex] = scalarValue; +} diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessObject.h b/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessObject.h new file mode 100644 index 0000000000..1bcb18d66a --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessObject.h @@ -0,0 +1,83 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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" + +class RigGridBase; +class RigActiveCellInfo; + + +//================================================================================================== +/// +//================================================================================================== +class RigActiveCellsResultAccessObject : public RigResultAccessObject +{ +public: + RigActiveCellsResultAccessObject(const RigGridBase* grid, std::vector* reservoirResultValues, const RigActiveCellInfo* activeCellInfo, const QString& resultName); + + 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: + const RigActiveCellInfo* m_activeCellInfo; + const RigGridBase* m_grid; + std::vector* m_reservoirResultValues; + QString m_resultName; +}; + + +/* + +class CellFaceScalarDataAccess : public Object +{ +public: + virtual double cellFaceScalar(size_t cellIndex, cvf::StructGridInterface faceId) const = 0; +}; + +class PlainCellFaceScalarDataAccess : public CellFaceScalarDataAccess +{ +public: + PlainCellFaceScalarDataAccess() + { + cellEdgeDataAccessObjects.resize(6); + } + + void setDataAccessObjectForFace(cvf::StructGridInterface faceId, cvf::StructGridScalarDataAccess* dataAccessObject) + { + cellEdgeDataAccessObjects[faceId] = dataAccessObject; + } + + virtual double cellFaceScalar( size_t cellIndex, cvf::StructGridInterface faceId ) const + { + cvf::StructGridScalarDataAccess* dataAccessObj = cellEdgeDataAccessObjects[faceId]; + if (dataAccessObj != NULL) + { + return dataAccessObj->cellScalar(cellIndex); + } + + return HUGE_VAL; + } +private: + cvf::Collection cellEdgeDataAccessObjects; +}; + +*/ diff --git a/ApplicationCode/ReservoirDataModel/RigAllGridCellsResultAccessObject.cpp b/ApplicationCode/ReservoirDataModel/RigAllGridCellsResultAccessObject.cpp new file mode 100644 index 0000000000..1d7b0ff8f1 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigAllGridCellsResultAccessObject.cpp @@ -0,0 +1,72 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RigAllGridCellsResultAccessObject.h" + +#include "RigGridBase.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigAllGridCellsResultAccessObject::RigAllGridCellsResultAccessObject(const RigGridBase* grid, std::vector* reservoirResultValues, const QString& resultName) + : m_grid(grid), + m_reservoirResultValues(reservoirResultValues), + m_resultName(resultName) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigAllGridCellsResultAccessObject::cellScalar(size_t localCellIndex) const +{ + if (m_reservoirResultValues->size() == 0 ) return HUGE_VAL; + + size_t globalGridCellIndex = m_grid->globalGridCellIndex(localCellIndex); + CVF_TIGHT_ASSERT(globalGridCellIndex < m_reservoirResultValues->size()); + + return m_reservoirResultValues->at(globalGridCellIndex); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigAllGridCellsResultAccessObject::cellFaceScalar(size_t localCellIndex, cvf::StructGridInterface::FaceType faceId) const +{ + return cellScalar(localCellIndex); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigAllGridCellsResultAccessObject::resultName() const +{ + return m_resultName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigAllGridCellsResultAccessObject::setCellScalar(size_t localCellIndex, double scalarValue) +{ + size_t globalGridCellIndex = m_grid->globalGridCellIndex(localCellIndex); + CVF_TIGHT_ASSERT(globalGridCellIndex < m_reservoirResultValues->size()); + + (*m_reservoirResultValues)[globalGridCellIndex] = scalarValue; +} diff --git a/ApplicationCode/ReservoirDataModel/RigAllGridCellsResultAccessObject.h b/ApplicationCode/ReservoirDataModel/RigAllGridCellsResultAccessObject.h new file mode 100644 index 0000000000..c503960ef5 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigAllGridCellsResultAccessObject.h @@ -0,0 +1,81 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RigActiveCellsResultAccessObject.h" + +class RigGridBase; + + +//================================================================================================== +/// +//================================================================================================== +class RigAllGridCellsResultAccessObject : public RigResultAccessObject +{ +public: + RigAllGridCellsResultAccessObject(const RigGridBase* grid, std::vector* reservoirResultValues, const QString& resultName); + + 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: + const RigGridBase* m_grid; + std::vector* m_reservoirResultValues; + QString m_resultName; +}; + + +/* + +class CellFaceScalarDataAccess : public Object +{ +public: + virtual double cellFaceScalar(size_t cellIndex, cvf::StructGridInterface faceId) const = 0; +}; + +class PlainCellFaceScalarDataAccess : public CellFaceScalarDataAccess +{ +public: + PlainCellFaceScalarDataAccess() + { + cellEdgeDataAccessObjects.resize(6); + } + + void setDataAccessObjectForFace(cvf::StructGridInterface faceId, cvf::StructGridScalarDataAccess* dataAccessObject) + { + cellEdgeDataAccessObjects[faceId] = dataAccessObject; + } + + virtual double cellFaceScalar( size_t cellIndex, cvf::StructGridInterface faceId ) const + { + cvf::StructGridScalarDataAccess* dataAccessObj = cellEdgeDataAccessObjects[faceId]; + if (dataAccessObj != NULL) + { + return dataAccessObj->cellScalar(cellIndex); + } + + return HUGE_VAL; + } +private: + cvf::Collection cellEdgeDataAccessObjects; +}; + +*/ diff --git a/ApplicationCode/ReservoirDataModel/RigResultAccessObject.h b/ApplicationCode/ReservoirDataModel/RigResultAccessObject.h index 021efe6846..caf9640931 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultAccessObject.h +++ b/ApplicationCode/ReservoirDataModel/RigResultAccessObject.h @@ -25,6 +25,9 @@ #include "cvfStructGrid.h" +//================================================================================================== +/// +//================================================================================================== class RigResultAccessObject : public cvf::Object { public: @@ -33,7 +36,7 @@ public: virtual QString resultName() const = 0; - virtual void setCellScalar(size_t cellIndex, double value) = 0; + virtual void setCellScalar(size_t localCellIndex, double scalarValue) = 0; }; diff --git a/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.cpp b/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.cpp index 218d8fb2f2..e47a35e2d5 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.cpp +++ b/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS +// 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 diff --git a/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.h b/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.h index 2183cd0fd1..d19a8ff386 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.h +++ b/ApplicationCode/ReservoirDataModel/RigResultAccessObjectFactory.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS +// 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