diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 4a23c7302f..25f9be656d 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -30,6 +30,8 @@ ${CEE_CURRENT_LIST_DIR}RigNNCData.h ${CEE_CURRENT_LIST_DIR}cvfGeometryTools.h ${CEE_CURRENT_LIST_DIR}cvfGeometryTools.inl ${CEE_CURRENT_LIST_DIR}RigPipeInCellEvaluator.h +${CEE_CURRENT_LIST_DIR}RigResultAccessor2d.h +${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -55,6 +57,7 @@ ${CEE_CURRENT_LIST_DIR}RigWellPath.cpp ${CEE_CURRENT_LIST_DIR}RigFault.cpp ${CEE_CURRENT_LIST_DIR}RigNNCData.cpp ${CEE_CURRENT_LIST_DIR}cvfGeometryTools.cpp +${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ReservoirDataModel/RigResultAccessor2d.h b/ApplicationCode/ReservoirDataModel/RigResultAccessor2d.h new file mode 100644 index 0000000000..87e0e2b3f5 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigResultAccessor2d.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 + +#pragma once + +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfVector2.h" +#include "cvfStructGrid.h" + +//================================================================================================== +/// +//================================================================================================== +class RigResultAccessor2d : public cvf::Object +{ +public: + virtual cvf::Vec2d cellScalar(size_t gridLocalCellIndex) const = 0; + virtual cvf::Vec2d cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const = 0; + + virtual QString resultName() const = 0; + +}; diff --git a/ApplicationCode/ReservoirDataModel/RigTernaryResultAccessor2d.cpp b/ApplicationCode/ReservoirDataModel/RigTernaryResultAccessor2d.cpp new file mode 100644 index 0000000000..ef3b02d8ad --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigTernaryResultAccessor2d.cpp @@ -0,0 +1,86 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RigTernaryResultAccessor2d.h" + +#include "RigResultAccessor.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigTernaryResultAccessor::RigTernaryResultAccessor() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// Requires at least two data objects present, asserts if more than one data accessor is NULL +//-------------------------------------------------------------------------------------------------- +void RigTernaryResultAccessor::setTernaryResultAccessors(RigResultAccessor* soil, RigResultAccessor* sgas, RigResultAccessor* swat) +{ + m_soilAccessor = soil; + m_sgasAccessor = sgas; + m_swatAccessor = swat; + + int nullPointerCount = 0; + if (!soil) nullPointerCount++; + if (!sgas) nullPointerCount++; + if (!swat) nullPointerCount++; + + CVF_ASSERT(nullPointerCount <= 1); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec2d RigTernaryResultAccessor::cellScalar(size_t gridLocalCellIndex) +{ + double soil = 0.0; + double swat = 0.0; + + if (m_soilAccessor.notNull()) + { + soil = m_soilAccessor->cellScalar(gridLocalCellIndex); + + if (m_swatAccessor.notNull()) + { + swat = m_swatAccessor->cellScalar(gridLocalCellIndex); + } + else + { + swat = 1.0 - soil - m_sgasAccessor->cellScalar(gridLocalCellIndex); + } + } + else + { + swat = m_swatAccessor->cellScalar(gridLocalCellIndex); + + soil = 1.0 - swat - m_sgasAccessor->cellScalar(gridLocalCellIndex); + } + + return cvf::Vec2d(soil, swat); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec2d RigTernaryResultAccessor::cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) +{ + return cellScalar(gridLocalCellIndex); +} diff --git a/ApplicationCode/ReservoirDataModel/RigTernaryResultAccessor2d.h b/ApplicationCode/ReservoirDataModel/RigTernaryResultAccessor2d.h new file mode 100644 index 0000000000..d1e85bcade --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigTernaryResultAccessor2d.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RigResultAccessor2d.h" + +class RigResultAccessor; + +//================================================================================================== +/// +//================================================================================================== +class RigTernaryResultAccessor : public RigResultAccessor2d +{ +public: + RigTernaryResultAccessor(); + + /// Requires two of the arguments to be present + void setTernaryResultAccessors(RigResultAccessor* soil, RigResultAccessor* sgas, RigResultAccessor* swat); + + /// Returns [SOil, SWat] regardless of which one of the three is missing. if Soil or SWat is missing, it is calculated + /// based on the two others + virtual cvf::Vec2d cellScalar(size_t gridLocalCellIndex); + virtual cvf::Vec2d cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId);; + +private: + cvf::ref m_soilAccessor; + cvf::ref m_sgasAccessor; + cvf::ref m_swatAccessor; +}; +